def Day(y, m, d): day = 0 if y % 400 == 0 or (y % 4 == 0 and y % 100 !=0): f = 1 else: f=0 for i in range(1, 13): if m > i: if i <=8: if i % 2 == 0: if i == 2: if f: day+=29 else: day+=28 elif i == 8: day+=31 else: day+=30 else: day+=31 else: if i % 2 == 0: day+=31 else: day+=30 else: day+=d break print(day) while True: try: year, mouth, day = map(int, input().split()) Day(year, mouth, day) except: break