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

using namespace std;

const vector<int> roundend = {25*24*60-1, 26*24*60-1, 27*24*60-1, 28*24*60-1, 30*24*60-1};

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int x, d, h, m;
    cin >> x >> d >> h >> m;
    int scr = roundend.at(x-1) - (d*24*60 + h*60 + m);
    if(x == 5  && (d < 29 || h < 2)) {
        scr -= 60;
    }
    cout << scr+1 << endl;
    return 0;
}