1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
#include<bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(0);
	cout.tie(0); cout.tie(0);
	int x, d, h, m;
	vector<int> konce = {24,25,26,27,29};	
	cin >> x >> d >> h >> m;
	int wynik = (konce[x-1] - d)*24*60;
	wynik += (24 - h) * 60;
	wynik -= m;
	if(x == 5) {
		if(d < 29 or h <= 1) {
			wynik -= 60;
		}	
	}	
	cout << wynik;
}