a, b, c = input().split(':')
a, b, c = int(a), int(b), int(c)
a = a * 3600
b = b * 60
print(a + b + c)
a, b, c = input().split(':')
a, b, c = int(a), int(b), int(c)
a = a * 3600
b = b * 60
print(a + b + c)