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
29
30
// Online C++ Compiler - Build, Compile and Run your C++ programs online in your favorite browser

#include<iostream>


int main()
{
    int x, d, h, m;
    std::cin >> x >> d >> h >> m;
    int result = 0;
    if (x == 1) {
        result = 60 * 24 * 2 - (d - 23) * 60 * 24 - h * 60 - m;
    }
    if(x == 2) {
        result = 60 * 24 * 3 - (d - 23) * 60 * 24 - h * 60 - m;
    }
    if(x == 3) {
        result = 60 * 24 * 4 - (d - 23) * 60 * 24 - h * 60 - m;
    }
    if(x == 4) {
        result = 60 * 24 * 5 - (d - 23) * 60 * 24 - h * 60 - m;
    }
    if(x == 5) {
        result = 60 * 24 * 7 - (d - 23) * 60 * 24 - h * 60 - m;
        if (d <= 28 || (d == 29 && h <= 2))result -= 60;
    }
    
    if (result < 0) result = 0;
    std::cout << result << '\n';
}