counter = 0 for n in range(1000, 10000): n = str(n) if int(n[0]) % 2 == 0: r = int(n[0]) + int(n[2]) + abs(int(n[1]) - int(n[3])) if r > 20: counter += 1 print(counter)