'''simple docstring'''

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



def 							UpperCamelCase__			(			a__      ):


						'''simple docstring'''






						_lowerCAmelCase										=0
						while number:
												# Increased Speed Slightly by checking every 5 digits together.
												sum_of_digits_squared += DIGITS_SQUARED[number % 1_0_0_0_0_0]
												number //= 1_0_0_0_0_0

						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
lowercase_     		= [None] * 1000_0000
lowercase_     		= True
lowercase_     		= False



def 							UpperCamelCase__			(			a__      ):


						'''simple docstring'''






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

						_lowerCAmelCase										=chain(next_number(a__      )      )
						_lowerCAmelCase										=number_chain

						while number < 1_0_0_0_0_0_0_0:
												_lowerCAmelCase										=number_chain
												number *= 1_0

						return number_chain



def 							UpperCamelCase__			(			a__ = 1_0_0_0_0_0_0_0      ):


						'''simple docstring'''






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

						return CHAINS[:number].count(a__      )


if __name__ == "__main__":
							import doctest

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






'''simple docstring'''

import unittest

from knapsack import knapsack as k
class   SCREAMING_SNAKE_CASE			(						unittest.TestCase):







		"""simple docstring"""






		def 		UpperCamelCase__       (   self				) ->     Optional[Any]:
								_lowerCAmelCase										=0
								_lowerCAmelCase										=[0]
								_lowerCAmelCase										=[0]
								_lowerCAmelCase										=len(__A				)
								self.assertEqual(k.knapsack(__A		,						__A		,						__A		,						__A				)		,						0				)

								_lowerCAmelCase										=[60]
								_lowerCAmelCase										=[10]
								_lowerCAmelCase										=len(__A				)
								self.assertEqual(k.knapsack(__A		,						__A		,						__A		,						__A				)		,						0				)






		def 		UpperCamelCase__       (   self				) ->     Tuple:
								_lowerCAmelCase										=3
								_lowerCAmelCase										=[1, 2, 3]
								_lowerCAmelCase										=[3, 2, 1]
								_lowerCAmelCase										=len(__A				)
								self.assertEqual(k.knapsack(__A		,						__A		,						__A		,						__A				)		,						5				)






		def 		UpperCamelCase__       (   self				) ->     Union[str, Any]:
								_lowerCAmelCase										=50
								_lowerCAmelCase										=[60, 100, 120]
								_lowerCAmelCase										=[10, 20, 30]
								_lowerCAmelCase										=len(__A				)
								self.assertEqual(k.knapsack(__A		,						__A		,						__A		,						__A				)		,						220				)


if __name__ == "__main__":
							unittest.main()





