1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
#include <iostream>

using namespace std;

int main() { 
    int x, d, h, m;
    cin >> x >> d >> h >> m;
    int t = 1440 * (23 + x - d) + 60 * (24 - h) - m;
    if(x == 5) {
        t += 1380;
        if (d == 29 && h > 2) t += 60;
    }
    cout << t << "\n";
}