'''simple docstring'''

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







def      UpperCamelCase_						(					snake_case_       :       int      )					->     Union[str, Any]:






 '''simple docstring'''

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

 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
_A			:      Optional[int]					      =				[None] * 10000000
_A			:      Dict					      =				True
_A			:      Union[str, Any]					      =				False







def      UpperCamelCase_						(					snake_case_       :       int      )					->     Tuple:






 '''simple docstring'''

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

 __lowerCAmelCase											=						chain(next_number(lowerCAmelCase__      )      )
 __lowerCAmelCase											=						number_chain

 while number < 10_00_00_00:
  __lowerCAmelCase											=						number_chain
  number *= 10

 return number_chain







def      UpperCamelCase_						(					snake_case_       :       int = 10_00_00_00      )					->     str:






 '''simple docstring'''

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

 return CHAINS[:number].count(lowerCAmelCase__      )


if __name__ == "__main__":
 import doctest

 doctest.testmod()
 print(f'{solution() = }')








def    __UpperCamelCase     (				lowerCAmelCase__							:				int = 5_0_0_0_0_0_0_0  ):
 __a :  int						=  set()
 __a :  str						=  int((limit - 2_4) ** (1 / 2)  )

 __a :  int						=  set(range(3  ,   prime_square_limit + 1  ,   2  )  )
 primes.add(2  )
 for p in range(3  ,   prime_square_limit + 1  ,   2  ):
  if p not in primes:
   continue
  primes.difference_update(set(range(p * p  ,   prime_square_limit + 1  ,   lowerCAmelCase__  )  )  )

 for primea in primes:
  __a :  Union[str, Any]						=  primea * primea
  for primea in primes:
   __a :  Union[str, Any]						=  primea * primea * primea
   if square + cube >= limit - 1_6:
    break
   for primea in primes:
    __a :  int						=  primea * primea * primea * primea
    __a :  Union[str, Any]						=  square + cube + tetr
    if total >= limit:
     break
    ret.add(lowerCAmelCase__  )

 return len(lowerCAmelCase__  )


if __name__ == "__main__":
      print(F"""{solution() = }""")
