x, d, h, m = [int (_) for _ in input().split()]
def to_minute_stamp(d, h, m):
return d*24*60+h*60+m - int((d==29 and h > 2) or d>29)*60
print(to_minute_stamp(x+24+int(x==5), 0, 0)-to_minute_stamp(d, h, m))
1 2 3 4 5 6 | x, d, h, m = [int (_) for _ in input().split()] def to_minute_stamp(d, h, m): return d*24*60+h*60+m - int((d==29 and h > 2) or d>29)*60 print(to_minute_stamp(x+24+int(x==5), 0, 0)-to_minute_stamp(d, h, m)) |
English