s = input()
y, ***p(int, s.split())
re = 0
m1 = 31
m2 = 0
# 判断是不是闰年
if str(y)[-2:] == '00': # 判断世纪闰年
if y % 400 == 0:
m2 = 29
else:
m2 = 28
else: # 判断普通闰年
if y % 4 == 0:
m2 = 29
else:
m2 = 28
m3 = 31
m4 = 30
m5 = 31
m6 = 30
m7 = 31
m8 = 31
m9 = 30
m10 = 31
m11 = 30
m12 = 31
arr = [m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12]
if m == 1:
re = d
print(re)
else:
for i in range(0,m-1):
re += arr[i]
print(re + d)