1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
#include <bits/stdc++.h>
using namespace std;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int x,d,h,m;
    cin >> x >> d >> h >> m;
    int ed = x+23+(x==5);
    int tm = (ed-d)*24*60 + 24*60-h*60-m;
    if (ed == 29 && (d < 29 || h < 2)) tm -= 60;
    cout << tm << "\n";
}