def day_cal(month):
global year
if month in [1,3,5,7,8,10,12]:
return 31
elif month in [4,6,9,11]:
return 30
elif month==2 and (year%400==0 or (year%100!=0 and year %4==0)):
return 29
else :
return 28
def prin_tot(tot):
if tot%10==1:
print("it is the "+str(tot)+'st day')
if tot%10==2:
print("it is the "+str(tot)+'nd day')
else :
print("it is the "+str(tot)+'th day')
print("year:")
year = int(input())
print("month:")
month = int(input())
print("day:")
day = int(input())
tot = 0
for i in range(1,month):
tot +=day_cal(i)
tot+=day
print(tot)
prin_tot(tot)