def ccnt(m, i): c = 0 for d in range(10, i + 1): a, b = map(int, str(d)) if a + b == m: c += 1 return c cnt = 0 for m in range(1, 13): if m < 10: cnt += 1 if m == 2: ccnt(2, 28) elif m in (4, 6, 9, 11): ccnt(m, 30) else: ccnt(m, 31)