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