1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
#include <bits/stdc++.h>
using namespace std;
int main() {
	int x, d, h, m;
	cin >> x >> d >> h >> m;
	int ans = 24 * 60 - (h * 60 + m);
	if (x == 5) {
		ans -= 60;
		if (d == 29 && h >= 3) {
			ans += 60;
		}
	}
	if (x == 5) {
		x = 6;
	}
	ans += (x + 23 - d) * 60 * 24;
	cout << ans << "\n";
}