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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <deque>
#include <map>
#include <queue>
#include <climits>
using namespace std;
using ll=long long;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);

    int d, h, m;
    ll x;
    cin >> x >> d >> h >> m;
    ll czas = d*24*60 + h*60 + m;
    if (x==1){
        x=25*24*60;
    }
    if (x==2){
        x=26*24*60;
    }
    if (x==3){
        x=27*24*60;
    }
    if (x==4){
        x=28*24*60;
    }
    if (x==5){
        x=30*24*60;
    }
    if(x==30*24*60 && czas<29*24*60+2*60+0){
        cout<<x-czas-60<<'\n';
    }
    else{
        cout<<x-czas<<'\n';
    }
    
    return 0;
}