1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include <iostream>
#include <ctime>


using namespace std;


static time_t ttStart, ttEnd;

static int x, d, h, m;


static void SetEndTime()
{
	tm tmTime;

	tmTime.tm_isdst = 0;

	tmTime.tm_sec = 0;
	tmTime.tm_min = 0;
	tmTime.tm_hour = 0;
	tmTime.tm_mday = 24 + x;
	tmTime.tm_mon = 2;
	tmTime.tm_year = 126;

	if (x == 5)
	{
		tmTime.tm_mday = 30;
	}

	ttEnd = mktime(&tmTime);
}


static void SetStartTime()
{
	tm tmTime;

	tmTime.tm_isdst = 0;

	tmTime.tm_sec = 0;
	tmTime.tm_min = m;
	tmTime.tm_hour = h;
	tmTime.tm_mday = d;
	tmTime.tm_mon = 2;
	tmTime.tm_year = 126;

	ttStart = mktime(&tmTime);
}


int main()
{
	// freopen("sample_input.txt", "r", stdin);
	// freopen("sample_output.txt", "w", stdout);

	cin >> x >> d >> h >> m;

	SetStartTime();
	SetEndTime();

	double dfSeconds = difftime(ttEnd, ttStart);

	int iSeconds = static_cast<int>(dfSeconds);

	int iMinutes = iSeconds / 60;

	if (x == 5)
	{
		if (!(d == 29 && h > 2))
		{
			iMinutes -= 60;
		}
	}

	cout << iMinutes;
}