y,m,d = map(int,input().split())
ls = [31,28,31,30,31,30,31,31,30,31,30,31]
if (y%100 != 0 and y%4 == 0) or (y%100 == 0 and y%400 ==0):
    ls[1] = 29
print(sum(ls[:m-1])+d)