


'''simple docstring'''



__lowercase     :						List[str]	=     [sum(int(c, 10) ** 2 for c in i.__str__()) for i in range(10_00_00)]






def   lowerCamelCase							(_SCREAMING_SNAKE_CASE				:       int       ):
     __a      :	List[Any]    =  0
     while number:
          # Increased Speed Slightly by checking every 5 digits together.
          sum_of_digits_squared += DIGITS_SQUARED[number % 100_000]
          number //= 100_000

     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     :						list[bool | None]	=     [None] * 10_00_00_00
__lowercase     :						Optional[Any]	=     True
__lowercase     :						Optional[int]	=     False






def   lowerCamelCase							(_SCREAMING_SNAKE_CASE				:       int       ):

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

     __a      :	Tuple    =  chain(next_number(lowercase_       )       )
     __a      :	int    =  number_chain

     while number < 10_000_000:
          __a      :	Optional[Any]    =  number_chain
          number *= 10

     return number_chain






def   lowerCamelCase							(_SCREAMING_SNAKE_CASE				:       int = 10_000_000       ):
     for i in range(1						,				lowercase_       ):
          if CHAINS[i] is None:
               chain(i + 1       )

     return CHAINS[:number].count(lowercase_       )


if __name__ == "__main__":
 import doctest

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







'''simple docstring'''



__lowercase     :						Optional[Any]	=     {'a': ['c', 'b'], 'b': ['d', 'e'], 'c': [], 'd': [], 'e': []}
__lowercase     :						List[str]	=     ['a', 'b', 'c', 'd', 'e']






def   lowerCamelCase							(_SCREAMING_SNAKE_CASE				:       List[Any]						,				_SCREAMING_SNAKE_CASE				:       Any						,				_SCREAMING_SNAKE_CASE				:       List[str]       ):
					__a      :	Any    =  start
					# add current to visited
					visited.append(_SCREAMING_SNAKE_CASE       )
					__a      :	Union[str, Any]    =  edges[current]
					for neighbor in neighbors:
										# if neighbor not in visited, visit
										if neighbor not in visited:
															__a      :	Dict    =  topological_sort(_SCREAMING_SNAKE_CASE						,				_SCREAMING_SNAKE_CASE						,				_SCREAMING_SNAKE_CASE       )
    # if all neighbors visited add current to sort
					sort.append(_SCREAMING_SNAKE_CASE       )
					# if all vertices haven't been visited select a new one to visit
					if len(_SCREAMING_SNAKE_CASE       ) != len(_SCREAMING_SNAKE_CASE       ):
										for vertice in vertices:
															if vertice not in visited:
																				__a      :	List[Any]    =  topological_sort(_SCREAMING_SNAKE_CASE						,				_SCREAMING_SNAKE_CASE						,				_SCREAMING_SNAKE_CASE       )
    # return sort
					return sort


if __name__ == "__main__":
	__lowercase     :						Union[str, Any]	=     topological_sort('a', [], [])
	print(sort)



