number_of_hours1 = int(input())
number_of_minutes1 = int(input())
number_of_seconds1 = int(input())
number_of_hours2 = int(input())
number_of_minutes2 = int(input())
number_of_seconds2 = int(input())
print(3600 * (number_of_hours2 - number_of_hours1) + 60 * (number_of_minutes2 - number_of_minutes1) + (number_of_seconds2 - number_of_seconds1))

