1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <bits/stdc++.h>

using namespace std;

int main(){
    int x, d, h, m; cin>>x>>d>>h>>m;
    int result = 0;
    if(x == 1){
        result += (24 - d) * 24 * 60;
    }
    if(x == 2){
        result += (25 - d) * 24 * 60;
    }
    if(x == 3){
        result += (26 - d) * 24 * 60;
    }
    if(x == 4){
        result += (27 - d) * 24 * 60;
    }   
    if(x == 5){
        if(d < 29 or d == 29 and h < 2) result = -60;
        result += (29 - d) * 24 * 60;
    } 
    result += (23 - h) * 60;
    result += (60 - m);
    cout<<result<<endl;
    return 0;
}