# 获取用户输入的年、月、日
year, month, day = [int(i) for i in input().split()]

# 初始化总天数为当前日期
total_days = day

# 定义每个月的天数列表,平年 2 月按 28 天算
month_days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]

# 判断是否为闰年,如果是闰年,2 月有 29 天
if (year % 400 == 0) or (year % 4 == 0 and year % 100 != 0):
    month_days[1] = 29

# 累加当前月份之前的所有月份的天数
for i in range(month - 1):
    total_days += month_days[i]

# 输出指定日期是该年的第几天
print(total_days)