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

int main(){
    int x, d, h, m, w = 1;
    cin >> x >> d >> h >> m;
    if(x == 5 && (d < 29 or h < 2)) w -= 60;
    if(x == 5) w += (29-d) * 1440;
    else if(x == 4) w += (27-d) * 1440;
    else if(x == 3) w += (26-d) * 1440;
    else if(x == 2) w += (25-d) * 1440;
    else if(x == 1) w += (24-d) * 1440;

    w += (23-h)*60;
    w += 59-m;

    cout << w;


}