year,month = map(int,input().split()) # 输入整型数
if month >= 1 and month <= 12: # 月份在1~12
if month in (1, 3, 5, 7, 8, 10, 12): # 大月
day = 31
elif month in (4, 6, 9, 11): # 小月
day = 30
else:
#以下两种情况之一都可以判断是闰年
if year % 400 == 0 or (year % 4 == 0 and year % 100 != 0):
day = 29
else:
day = 28
print(day)