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

using namespace std;
using ll = long long;

ll tom(int d, int h, int m){
    ll t = (d-23)*24*60 + h*60 +m;
    if(d== 29 && h >=3) t-=60;
    return t;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int x,d,h,m;
    cin >> x >> d >> h >>m ;
    int ed;
    if(x== 1) ed = 24;
    else if(x==2) ed =25;
    else if(x==3) ed = 26;
   else  if(x==4) ed = 27;
    else ed = 29;

     ll st = tom(d,h,m);
     ll fin = tom(ed,23,59);
     cout << fin-st +1<< '\n';
        return 0;
}