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