# Analyze: 闰年

def is_leap(year):
    return (year % 4 == 0 and year % 100 != 0) or year % 400 == 0
        
    
def find_day(year, month, day):
    days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
    result = 0
    
    if is_leap(year): 
        days[1] = 29
    
    for i in range(month-1):
        result += days[i]    
    return result + day

while True:
    try:
        year, month, day = map(int, input().split())
        result = find_day(year, month, day)
        print(result)
    except:
        break