






'''simple docstring'''

A:      Dict  				=				[sum(int(c, 1_0) ** 2 for c in i.__str__()) for i in range(1_0_0_0_0_0)]






def 	_UpperCAmelCase    (  a		:	int							)			->			int:





						"""simple docstring"""
						lowercase_      :   Any        =			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
A:      list[bool | None]  				=				[None] * 1_0_0_0_0_0_0_0
A:      Optional[Any]  				=				True
A:      List[Any]  				=				False






def 	_UpperCAmelCase    (  a		:	int							)			->			bool:





						"""simple docstring"""

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

						lowercase_      :   Union[str, Any]        =			chain(next_number(a							)							)
						lowercase_      :   Any        =			number_chain

						while number < 1_0_0_0_0_0_0_0:
												lowercase_      :   Dict        =			number_chain
												number *= 1_0

						return number_chain






def 	_UpperCAmelCase    (  a		:	int = 1_0_0_0_0_0_0_0							)			->			int:





						"""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'''

class 							__magic_name__     :







	"""simple docstring"""



	def __init__(							self  ,      _lowercase       )						->  Union[str, Any]:
							lowercase_      :   Dict        =			n
							lowercase_      :   Dict        =			[None] * self.n
							lowercase_      :   Tuple        =			0  # index of the first element
							lowercase_      :   List[Any]        =			0
							lowercase_      :   List[Any]        =			0
	def __len__(							self       )						->  int:
							return self.size
	def        lowerCamelCase__		(							self       )						->  bool:
							return self.size == 0
	def        lowerCamelCase__		(							self       )						->  List[Any]:
							return False if self.is_empty() else self.array[self.front]
	def        lowerCamelCase__		(							self  ,      _lowercase       )						->  Any:
							if self.size >= self.n:
													raise Exception('QUEUE IS FULL'       )

							lowercase_      :   Tuple        =			data
							lowercase_      :   List[Any]        =			(self.rear + 1) % self.n
							self.size += 1
							return self







	def        lowerCamelCase__		(							self       )						->  Any:
							if self.size == 0:
													raise Exception('UNDERFLOW'       )

							lowercase_      :   Dict        =			self.array[self.front]
							lowercase_      :   Tuple        =			None
							lowercase_      :   int        =			(self.front + 1) % self.n
							self.size -= 1
							return temp
