import sys

data=sys.stdin.readline().split(" ")
for i in range(len(data)):
    data[i]=int(data[i])
year=data[0]

d={}

d={1:31,2:28,3:31,4:30,5:31,6:30,7:31,8:31,9:30,10:31,11:30,12:31}

if year%400==0 or year%4==0 and year%100!=0:
    d[2]=29

month=data[1]
day=data[2]

sum=0
for i in range(1,month):
    sum=sum+d[i]
sum=sum+day

print(sum)