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

int main()
{
    int x, d, h, m, result;
    (void)scanf("%d %d %d %d", &x, &d, &h, &m);
    result = (23 + x - d)*24*60 + (23-h)*60 + (60-m);
    if(x == 5){
        result += 24*60;
        if(!(d==29 && h>2)){
            result-=60;
        }
    }
    printf("%d\n", result);
    fflush(stdout);
    return 0;
}