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

using namespace std;

int main()
{
    int x, d, m, h;
    cin>>x>>d>>h>>m;
    if(x <= 4) {
        int dl = x + 23 - d;
        cout<<dl*1440 + (23 - h) * 60 + (60 - m) << "\n";
    } else {
        int dl = 29 - d;
        int res = dl*1440 + (23 - h) * 60 + (60 - m);
        if((d != 29) || (h < 2))
            res -= 60;
        cout<<res<<"\n";
    }
}