ans = 0
for x in range(2, 10 ** 7):
    while x != 1 and x != 89:
        y = 0
        while x > 0:
            y += (x % 10) ** 2
            x //= 10
        x = y
    if x == 89:
        ans += 1
print(f'Answer: {ans}')

99759f47eef1a0ceca24d9bf066f4d5b74f38c74
<mask token>

<mask token>
for x in range(2, 10 ** 7):
    while x != 1 and x != 89:
        y = 0
        while x > 0:
            y += (x % 10) ** 2
            x //= 10
        x = y
    if x == 89:
        ans += 1
print(f'Answer: {ans}')

ans = 0
for x in range(2, 10 ** 7):
    while x != 1 and x != 89:
        y = 0
        while x > 0:
            y += (x % 10) ** 2
            x //= 10
        x = y
    if x == 89:
        ans += 1
print(f'Answer: {ans}')
