def leap_year(year):
if year % 400 == 0:
return True
else:
if year % 4 == 0 and year % 100 != 0:
return True
else:
return False
days_common = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
days_leap = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
while True:
try:
year, month, day = list(map(int, input().split()))
if leap_year(year):
print(sum(days_leap[:month-1]) + day)
else:
print(sum(days_common[:month-1]) + day)
except:
break