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
#include <bits/stdc++.h>


using namespace std;


vector <tuple <int,int,int>> endOfRound = {
    {24, 23, 59},
    {25, 23, 59},
    {26, 23, 59},
    {27, 23, 59},
    {29, 23, 59}
};


int main() {
    ios_base::sync_with_stdio(false);

    int x, d, h, m;
    cin >> x >> d >> h >> m;

    int timeTaken = 0;
    while (make_tuple(d, h, m) != endOfRound[x - 1]) {
        m++;

        if (m == 60) {
            m = 0, h++;
        }

        if (h == 24) {
            h = 0, d++;
        } else if (d == 29 && h == 2) {
            assert(m == 0);
            h++;
        }

        timeTaken++;
    }


    cout << timeTaken + 1;

    return 0;
}