while True:
try:
year, month, day = [int(i) for i in input().split()]
total_days = day
for i in range(2, month + 1):
if i == 3:
if year % 4 == 0 and year % 100 != 0:
total_days += 29
else:
total_days += 28
elif i in [2, 4, 6, 8, 9, 11]:
total_days += 31
else:
total_days += 30
print(total_days)
except:
break