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()
{
	int x, d, h, m;
	cin >> x >> d >> h >> m;
	if (x == 5 && d < 29)
	    h++;
	else if (x == 5 && h <= 2)
	    h++;
	if (x == 5)
		x++;
	cout << (23 + x - d + 1) * 24 * 60 - h * 60 - m;

	return 0;
}