'''
解题思路:
输入年月日并进行相关初始化(字符转数字)。
构建判断平年闰年的子函数lc_year,
以及返回日期天数的子函数print_data,
里面有调用平年闰年判断子函数。
然后打印输出返回日期天数子函数的返回值。
'''

time = input().split()
year = int(time[0])
month = int(time[1])
data = int(time[2])
#判断是平年还是闰年,如果是闰年则返回True,否则返回False
def lc_year(y):
    leap_year = False

    if y % 400 == 0:
        leap_year = True
    elif y % 100 == 0:
        leap_year = False
    elif y % 4 == 0:
        leap_year = True
    else:
        leap_year = False

    return leap_year
#输入日期(年月日),然后返回天数,存储每个月天数的数组默认为平年,如果是闰年则2月需要加1天
def print_data(y,m,d):
    datas = d
    months_datas = [31,28,31,30,31,30,31,31,30,31,30,31]

    for i in range(m-1):
        datas += months_datas[i]

    if lc_year(y) and m > 2:
        datas += 1
    
    return datas
#打印输出输入日期的天数
print(print_data(year,month,data))