1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int x, d, h, m;
    cin >> x >> d >> h >> m;

    int ld;
    if (x == 5 && (d < 29 || h < 3))
    {
        h++;
    }

    ld = (23 + x - d);
    if (x == 5)
    {
        ld += 1;
    }
    cout << 60 - m + (23 - h) * 60 + ld * 60 * 24 << "\n";
}