count = 0 for m in range(1,12): for d in range(1,31): if (d < 10 and m == d) or (10 <= d and m == d//10 + d%10): count += 1 print(count)