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

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    int x,d,h,m;
    cin>>x>>d>>h>>m;
    int skipt = 28 * 1440 + 120;
    int endt=(23 + x + (x==5))*1440;
    int startt=(d-1)*1440 + 60*h + m;
    int res = endt - startt;
    if (endt>skipt and startt<=skipt) res-=60;
    cout<<res;
    return 0;
}