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
#include <iostream>


// mega szybkie rozwiazanie xd

// d, (h, m)
std::pair<int, std::pair<int, int>> next_thing(std::pair<int, std::pair<int, int>> xx) {
    auto [d, hm] = xx;
    auto [h, m] = hm;
    m++;
    if (m == 60) {
        m = 0;
        h++;
    }
    if (h == 24) {
        d++;
        h = 0;
    }
    if (d == 29 && h == 2) {
        h = 3;
    }
    return {d, {h,m}};
}

int main() {
    int end_h = 0;
    int end_m = 0;
    int end_d = 0;
    int x,d,h,m;
    std::cin >> x >> d >> h >> m;
    if (x == 1) {
        end_d = 25;
    }
    if (x == 2) {
        end_d = 26;
    }
    if (x == 3) {
        end_d = 27;
    }
    if (x == 4) {
        end_d = 28;
    }
    if (x == 5) {
        end_d = 30;
    }
    
    auto dhm = std::make_pair(d, std::make_pair(h, m));
    auto end_dhm = std::make_pair(end_d, std::make_pair(end_h, end_m));
    int i;
    for (i=0; dhm != end_dhm; i=i+1,dhm=next_thing(dhm));
    std::cout << i << '\n';
}