year=input()
month=input()
day=input()
days = int(day)
_30_month = {4, 6, 9, 11}
_31_month = {1, 3, 5, 7, 8, 10, 12}
if (int(year)%4==0 and int(year)%100!=0) or (int(year)%400==0):
for i in range(1, int(month)):
if i in _30_month:
days += 30
elif i in _31_month :
days += 31
else:
days += 29
print('{}年{}月{}日是{}年第{}天'.format(year,month,day,year,days))
else:
for i in range(1, int(month)):
if i in _30_month:
days += 30
elif i in _31_month :
days += 31
else:
days += 28
print('{}年{}月{}日是{}年第{}天'.format(year,month,day,year,days))