


'''simple docstring'''
__snake_case							      =     [sum(int(c, 10) ** 2 for c in i.__str__()) for i in range(100000)]


def 			a      (			__a   )  ->	int:



					'''simple docstring'''






					UpperCamelCase__   :List[str]												= 0
					while number:
										# Increased Speed Slightly by checking every 5 digits together.
										sum_of_digits_squared += DIGITS_SQUARED[number % 100000]
										number //= 100000

					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
__snake_case							      =     [None] * 10000000
__snake_case							      =     True
__snake_case							      =     False


def 			a      (			__a   )  ->	bool:



					'''simple docstring'''






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

					UpperCamelCase__   :Dict												= chain(next_number(__a   )   )
					UpperCamelCase__   :int												= number_chain

					while number < 10000000:
										UpperCamelCase__   :Optional[int]												= number_chain
										number *= 10

					return number_chain


def 			a      (			__a = 10000000   )  ->	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'''
from ...utils import (
    OptionalDependencyNotAvailable,
    is_flax_available,
    is_torch_available,
    is_transformers_available,
)


try:
		if not (is_transformers_available() and is_torch_available()):
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		from ...utils.dummy_torch_and_transformers_objects import *  # noqa F403
else:
		from .multicontrolnet import MultiControlNetModel
		from .pipeline_controlnet import StableDiffusionControlNetPipeline
		from .pipeline_controlnet_imgaimg import StableDiffusionControlNetImgaImgPipeline
		from .pipeline_controlnet_inpaint import StableDiffusionControlNetInpaintPipeline


if is_transformers_available() and is_flax_available():
		from .pipeline_flax_controlnet import FlaxStableDiffusionControlNetPipeline