month_days = {1: 0, 2: 31, 3: 59, 4: 90, 5: 120, 6: 151, 7: 181, 8: 212, 9: 243, 10: 273, 11: 304, 12: 334}
while True:
    try:
        yy, mm, dd = map(int, input().split())
    except:
        break
    else:
        if (yy % 4 == 0 and yy % 100 != 0) or yy % 400 == 0:  # 闰年
            print(dd + month_days[mm] if mm <= 2 else month_days[mm] + dd + 1)
        else:  # 非闰年
            print(month_days[mm] + dd)