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 konce[] = {
	0, 2 * 24 * 60, 3 * 24 * 60, 4 * 24 * 60, 5 * 24 * 60, 7 * 24 * 60 - 60};

int main() {
	ios::sync_with_stdio(0), cin.tie(0);

	int x, d, h, m;
	cin >> x >> d >> h >> m;

	int t = (d - 23) * 24 * 60 + h * 60 + m;
	if (d == 29 && h >= 3)
		t -= 60;

	cout << konce[x] - t << '\n';
}