1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
#include <bits/stdc++.h>
using namespace std;
int F(int d,int h,int m){return d*1440+h*60+m-(d>29||(d==29&&h>2)?60:0);}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int x,d,h,m,A[]={0,25,26,27,28,30};
    cin>>x>>d>>h>>m;
    cout<<F(A[x],0,0)-F(d,h,m)<<'\n';
    return 0;
}