






"""simple docstring"""







_UpperCamelCase					      =  [sum(int(c, 10) ** 2 for c in i.__str__()) for i in range(100000)]

def _a			(		_snake_case							):







      """simple docstring"""






      UpperCAmelCase          =	0
      while number:
            # Increased Speed Slightly by checking every 5 digits together.
            sum_of_digits_squared += DIGITS_SQUARED[number % 10_0000]
            number //= 10_0000

      return sum_of_digits_squared


# There are 2 Chains made,
# One ends with 89 with the chain member 58 being the one which when declared first,
# there will be the least number of iterations for all the members to be checked.

# The other one ends with 1 and has only one element 1.

# So 58 and 1 are chosen to be declared at the starting.

# Changed dictionary to an array to quicken the solution
_UpperCamelCase					      =  [None] * 10000000
_UpperCamelCase					      =  True
_UpperCamelCase					      =  False

def _a			(		_snake_case							):







      """simple docstring"""






      if CHAINS[number - 1] is not None:
            return CHAINS[number - 1]  # type: ignore

      UpperCAmelCase          =	chain(next_number(_snake_case							)							)
      UpperCAmelCase          =	number_chain

      while number < 1000_0000:
            UpperCAmelCase          =	number_chain
            number *= 10

      return number_chain

def _a			(		_snake_case = 1000_0000							):







      """simple docstring"""






      for i in range(1				,	_snake_case							):
            if CHAINS[i] is None:
                  chain(i + 1							)

      return CHAINS[:number].count(_snake_case							)


if __name__ == "__main__":
  import doctest

  doctest.testmod()
  print(F"""{solution() = }""")











"""simple docstring"""







from __future__ import annotations

def _a			(		_snake_case				,	_snake_case = None				,	_snake_case = None							):







      """simple docstring"""






      if start is None:
            UpperCAmelCase          =	0

      if end is None:
            UpperCAmelCase          =	len(_snake_case							) - 1

      if start >= end:
            return

      UpperCAmelCase          =	(start + end) // 2

      slowsort(_snake_case				,	_snake_case				,	_snake_case							)
      slowsort(_snake_case				,	mid + 1				,	_snake_case							)

      if sequence[end] < sequence[mid]:
            UpperCAmelCase      , UpperCAmelCase          =	sequence[mid], sequence[end]

      slowsort(_snake_case				,	_snake_case				,	end - 1							)


if __name__ == "__main__":
  from doctest import testmod

  testmod()



