import sys

for line in sys.stdin:
    y, m, d = map(int, line.split())#循环输入年,月,日
    ans = d#先把当前月份的天数加进去
    date = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]#存储平年每月天数
    for i in range(m - 1):#遍历添加之前每月的天数
        ans += date[i]
        if i == 1 and (y % 4 == 0 and y % 100 != 0 or y % 400 == 0):#若遇到闰年,且月份大于2
            ans += 1
    print(ans)