import sys
while True:
    try:
        month =[0,31,28,31,30,31,30,31,31,30,31,30,31]
        y,m,d=map(int,input().split())
        day=0
        #判断闰年
        if y%4==0 and y%100!=0 or y%400==0:
            month[2]=29
        day+=sum(month[1:m])
        day+=d
        print(day)
    except:
        break