start_h=int(input())
start_m=int(input())
end_h=int(input())
end_m=int(input())
print((end_h*60+end_m)-(start_h*60+start_m))