import math M = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] ans = 0 for i, m in enumerate(M): for j in range(1, m+1): if (j%10 + math.floor(j/10)) == (i+1): ans += 1 print(ans)