import sys

a, b, c = map(int, input().split())

total = 0

runyear_day = [31,29,31,30,31,30,31,31,30,31,30,31]
pingyear_day = [31,28,31,30,31,30,31,31,30,31,30,31]

if (a % 4 == 0 and a % 100 != 0) or a % 400 == 0:
    for i in range(b-1):
        total += runyear_day[i]
    total += c
else:
    for k in range(b-1):
        total += pingyear_day[k]
    total += c
print(total)