1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int x, d, h, m;
    cin>>x>>d>>h>>m;
    int res=0;
    int datakon;
    if(x==5&&!(d==29&&h>2)) res-=60;
    if(x==5)datakon=29;
    else datakon=23+x;
    res+=(datakon-d)*(24*60);
    //cout<<res<<endl;
    res+=60*(23-h);
    res+=(60-m);
    cout<<res;
}