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
29
30
31
32
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
#define vc vector
#define st first
#define nd second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)a.size()
#define pub push_back
#define pob pop_back

void program() {
    ll x, d, h, m;
    cin >> x >> d >> h >> m;
    ll a = (d - 22 - x) * 1440;
    a += (h - 12) * 60 + m;
    if (x == 5 and (d <= 28 or h < 2))
        a += 60;
    ll b = 2160;
    if (x == 5)
        b += 1440;
    cout << b - a << "\n";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    program();
    return 0;
}