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(false);
	cin.tie(NULL);	
	int x, d, h, m;
	cin >> x >> d >> h >> m;
	int fd;
	if (x == 1) fd = 24;
	else if (x == 2) fd = 25;
	else if (x == 3) fd = 26;
	else if (x == 4) fd = 27;
	else if (x == 5) fd = 29;
	int res = (fd-d)*24*60 + 23*60+59 - (h*60+m);
	if (x == 5 && (d < 29 || (d == 29 && h < 2))) {
		res -= 60;
	}
	cout << res+1 << "\n";
}