# 平年:365天
# 闰年:366天
# 闰年的条件:能被4整除且不能被100整除,或者能被400整除。

# 每月的天数:
# 2月份:28(平年)/ 29(闰年)
# 1,3,5,7,8,10,12月份:31天
# 4,6,9,11月份:30天


year, month, day = map(int, input().split())

if year % 4 == 0 and year % 100 != 0 or year % 400 == 0:
    month_days = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
else:
    month_days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]

days = sum(month_days[: month - 1]) + day

print(days)