from datetime import datetime def check_31(month, first, second) -> bool: day = second * 10 + first try: datetime(2015, month, day) return month == first + second except Exception: return False def main(): count = 0 for month in range(1, 13): for second in range(0, 4): for first in range(0, 10): if second == first and second == 0: continue if second == 3 and first == 1: if check_31(month, first, second): count += 1 break day_sum = first + second if month < day_sum: break if month == day_sum: count += 1 print(count) if __name__ == '__main__': main()