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

int koniec[6] = {0, 25, 26, 27, 28, 30};

int main()
{
    int x, d, h, m;
    cin >> x >> d >> h >> m;
    int res = 0;
    while( !( d == koniec[x] && h == 0 && m == 0 ) ){
        res++;
        m++;
        if( m == 60 ){
            m = 0;
            h++;
        }
        if( h == 24 ){
            h = 0;
            d++;
        }
        if( d == 29 && h == 2 ){
            h = 3;
        }
    }
    cout << res << "\n";
    return 0;
}