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
#include <bits/stdc++.h>
using namespace std;

int last_shit(int d, int h, int m){
    d -= 27;

    if (d != 2 || h<3) h ++;

    h += 24*d;

    m += 60*h;

    cout << 3*24*60 - m;
    return 0;
}

int main(){
	int x, d, h, m;
	cin >> x >> d >> h >> m;

	if (x == 5) return last_shit(d, h, m);

	d -= x+22;

	h += 24*d;

	m += 60*h;

	cout << 48 * 60 - m;
return 0;}