while 1: try: year,month = map(int,input().split()) if month == 2: if (year % 4 == 0) and (year % 100 != 0) or (year % 400 == 0): day = 29 else: day = 28 else: if month in (4,6,9,11): day = 30 else: day = 31 print(day) except: break