from dataclasses import make_dataclass
while True:
    try:
        m_d = [31,28,31,30,31,30,31,31,30,31,30,31] # 平年2月有28天
        y,m,d = map(int,input().split())
        if (y%4 == 0 and y%100 !=0) or (y%400 == 0): # 闰年
            m_d[1] = 29
        days = d + sum(m_d[0:m-1])
        print(days)
    except:
        break