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;

typedef long long ll;

ll x, d, h, m;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> x >> d >> h >> m;
    d -= 23;
    ll minuty1 = (d * 24 + h) * 60 + m;
    if (minuty1 >= (6 * 24 + 2) * 60) minuty1 -= 60;
    ll minuty2 = 24 * 60 * (x+1);
    if (x == 5) minuty2 += 23 * 60;
    //cout << minuty1 << ' ' << minuty2;
    cout << minuty2 - minuty1;

    return 0;
}