1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int x, d, h, m;
    cin >> x >> d >> h >> m;
    if (x == 5)
    {
        x++;
    }
    int final = ((24 + x) * 24) * 60;
    int act = (((d * 24) + h) * 60) + m;
    if (x == 6 && (d < 29 || h < 3))
    {
        final -= 60;
    }
    cout << final - act << "\n";
}