1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
#include <bits/stdc++.h>
using namespace std;
int main(){
    int x,d,h,m;
    cin >> x >> d >> h >> m;
    if(d==29 and h>=3){
        h--;
    }
    int curTime = (d-23)*1440 + h*60 + m;
    int endTime = (x == 5) ? 6*1440 + 23*60 : x*1440 + 24*60;
    cout << endTime - curTime;
}