# put your python code here
time1=int(input()),int(input()),int(input())
time2=int(input()),int(input()),int(input())
print(((time2[0]-time1[0]) * 3600) + ((time2[1]-time1[1]) * 60) + (time2[2]-time1[2]))
