1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <bits/stdc++.h>
#include <cmath>
#define ll long long
#define fir first
#define sec second
using namespace std;
int x,d,h,m;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>x>>d>>h>>m;
    ll odp=0;

        if(x!=5)odp+=(23+x-d)*(24*60);
            if(x==5)odp+=(29-d)*1440;
        if(x==5 && d<29)odp-=60;
        if(x==5 && d==29 && h<=2)odp-=60;
odp+=(24-h-1)*60;
odp+=60-m;
        cout<<odp;


}