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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//proba kodu nr 67 :(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define tak cout<<"TAK\n"
#define yes cout<<"YES\n"
#define nie cout<<"NIE\n"
#define no cout<<"NO\n"
using ll = long long;
using ld = long double;
using pll = pair<ll,ll>;
using pdd = pair<ld,ld>;
#define vec vector
#define all(x) (x).begin(), (x).end()
#define sz(x) (x).size()
#define linijki ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mapa map<ll,ll>
#define umapa unordered_map<ll,ll>
#define se set<ll>
#define ff first
#define ss second
#define str string
const ll alph = 26;
const ll BIN6 = (1LL << 20);
const ll BIN9 = (1LL << 30);
const ll BIN18 = (1LL << 60);
const ll INF5 = 100000;
const ll INF6 = 1000000;
const ll INF9 = 1000000000;
const ll INF18 = 1000000000000000000;
const ld DINF5 = 1e5L;
const ld DINF6 = 1e6L;
const ld DINF9 = 1e9L;
const ll MOD = 1000000033;

int main() {
    linijki;
    
    ll x,d,h,m;
    cin>>x>>d>>h>>m;
    if(x==1){
        ll do_kiedy = 25 * 24 * 60;
        ll od_kiedy = 24 * 60 * d + 60 * h + m;
        cout << do_kiedy - od_kiedy;
    }
    else if(x==2){
        ll do_kiedy = 26 * 24 * 60;
        ll od_kiedy = 24 * 60 * d + 60 * h + m;
        cout << do_kiedy - od_kiedy;
    }
    else if(x==3){
        ll do_kiedy = 27 * 24 * 60;
        ll od_kiedy = 24 * 60 * d + 60 * h + m;
        cout << do_kiedy - od_kiedy;
    }
    else if(x==4){
        ll do_kiedy = 28 * 24 * 60;
        ll od_kiedy = 24 * 60 * d + 60 * h + m;
        cout << do_kiedy - od_kiedy;
    }
    else if(x==5){
        
        ll do_kiedy = 30 * 24 * 60;
        ll od_kiedy = 24 * 60 * d + 60 * h + m;
        ll czy_zmiana = do_kiedy - 22 * 60;
        if(od_kiedy <= czy_zmiana){
            od_kiedy += 60;
        }
        cout << do_kiedy - od_kiedy;
    }
    
    return 0;
}