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
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define st first
#define nd second

void solve() {
    int x, d, h, m; cin >> x >> d >> h >> m;
    int res = 24*60 - 60*h - m;
    res += ((x+23+(x == 5)) - d)*24*60;
    if (x == 5 && !(d == 29 && h >= 3)) res -= 60;
    cout << res << '\n';
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}