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
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
void solve(){
   int x, d, h, m; cin>>x>>d>>h>>m;

   int nowminutes = (d-23)*1440 + h * 60 + m;
   if(d == 29 && h >= 3) nowminutes -= 60;

   vector<int> ending = {2*1440, 3*1440, 4*1440, 5*1440, 7*1440 - 60};

   x -= 1;
   cout<<ending[x] - nowminutes;
}
 
int main(){
    ios_base::sync_with_stdio(0);
    cout.tie(0); cin.tie(0);
 
    int sets; sets=1;
    while(sets--){
        solve();
    }
    return 0;
}