1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    int x, d, h, m;
    cin >> x >> d >> h >> m;
    if (x < 5) {
        cout << (23 + x - d) * 24 * 60 + (24 - h) * 60 + 0 - m << "\n";
    } else {
        if (d * 100 + h < 2902) {
            cout << (29 - d) * 24 * 60 + (24 - h - 1) * 60 + 0 - m << "\n";
        } else {
            cout << (29 - d) * 24 * 60 + (24 - h) * 60 + 0 - m << "\n";
        }
    }

    return 0;
}