1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
#include<bits/stdc++.h>

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int x, d, h, m;
    cin >> x >> d >> h >> m;

    int q = x*60*24 + 60*12;
    if(x > 4) q += 23*60;
    int p = (d - 23)*60*24 + (h - 12)*60 + m;
    if(d > 28 && h > 2) p -= 60; 
    cout << q - p << "\n";
}