1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
#include <bits/stdc++.h>
using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cout.tie(0);
	cin.tie(0);
	int x, d, h, m;
	cin >> x >> d >> h >> m;
	vector<int> odp = {0, 24, 25, 26, 27, 29};
	int ans = ((odp[x] - d + 1) * 24 - h) * 60 - m;
	if (x == 5 and (d < 29 || (d == 29 && h < 2))) {
		ans -= 60;
	}
	cout << ans << '\n';
	return 0;
}