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

int main(){
    long long x, d, h, m, curr;
    cin >> x >> d >> h >> m;
    curr = (d-22)*1440+h*60+m;
    long long last = (2+x)*1440;
    if(x==5) last+=1440;
    long long output = last-curr;
    if(x==5){
        if(d<29 || (d==29 && h<2)) output-=60;
    }
    cout << output;
}