while True:
    try:
        MonthsToDays = [0,31,28,31,30,31,30,31,31,30,31,30]    #12月,只需要加上11月的总天数,而1月就是0
        years, months, days = map(int, input().split())
        allDays = days
        if years % 100 !=0 and years % 4 == 0 and months > 2:    #闰年,二月份有29天;所以月份要大于2才+1
            allDays += 1
        for day in range(1, months):
            allDays += MonthsToDays[day]
        print(allDays)
    except:
        break