


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







def SCREAMING_SNAKE_CASE	(			__lowerCAmelCase				)    ->				int:
  snake_case__						= 0
  while number:
    # Increased Speed Slightly by checking every 5 digits together.
    sum_of_digits_squared += DIGITS_SQUARED[number % 10_0000]
    number //= 10_0000

  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
lowerCamelCase__							:						list[bool | None]							     =   [None] * 1_0_0_0_0_0_0_0
lowerCamelCase__							:						Optional[Any]							     =   True
lowerCamelCase__							:						Union[str, Any]							     =   False







def SCREAMING_SNAKE_CASE	(			__lowerCAmelCase				)    ->				bool:

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

  snake_case__						= chain(next_number(__lowerCAmelCase				)				)
  snake_case__						= number_chain

  while number < 1000_0000:
    snake_case__						= number_chain
    number *= 10

  return number_chain







def SCREAMING_SNAKE_CASE	(			__lowerCAmelCase = 1000_0000				)    ->				int:
  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() = }""")





from copy import deepcopy
class 		__magic_name__						:





     '''simple docstring'''



     def __init__(					self:int     ,		_a:list[int] | None = None     ,		_a:int | None = None   ):

       if arr is None and size is not None:
         snake_case__						= size
         snake_case__						= [0] * size
       elif arr is not None:
         self.init(_a   )
       else:
         raise ValueError('''Either arr or size must be specified'''   )

     def 	SCREAMING_SNAKE_CASE__						(					self:Any     ,		_a:list[int]   ):
       snake_case__						= len(_a   )
       snake_case__						= deepcopy(_a   )
       for i in range(1     ,		self.size   ):
         snake_case__						= self.next_(_a   )
         if j < self.size:
           self.tree[j] += self.tree[i]

     def 	SCREAMING_SNAKE_CASE__						(					self:Any   ):
       snake_case__						= self.tree[:]
       for i in range(self.size - 1     ,		0     ,		-1   ):
         snake_case__						= self.next_(_a   )
         if j < self.size:
           arr[j] -= arr[i]
       return arr

     @staticmethod
     def 	SCREAMING_SNAKE_CASE__						(					_a:int   ):
       return index + (index & (-index))

     @staticmethod
     def 	SCREAMING_SNAKE_CASE__						(					_a:int   ):
       return index - (index & (-index))

     def 	SCREAMING_SNAKE_CASE__						(					self:List[Any]     ,		_a:int     ,		_a:int   ):
       if index == 0:
         self.tree[0] += value
         return
       while index < self.size:
         self.tree[index] += value
         snake_case__						= self.next_(_a   )

     def 	SCREAMING_SNAKE_CASE__						(					self:Dict     ,		_a:int     ,		_a:int   ):
       self.add(_a     ,		value - self.get(_a   )   )

     def 	SCREAMING_SNAKE_CASE__						(					self:Optional[Any]     ,		_a:int   ):
       if right == 0:
         return 0
       snake_case__						= self.tree[0]
       right -= 1  # make right inclusive
       while right > 0:
         result += self.tree[right]
         snake_case__						= self.prev(_a   )
       return result

     def 	SCREAMING_SNAKE_CASE__						(					self:Dict     ,		_a:int     ,		_a:int   ):
       return self.prefix(_a   ) - self.prefix(_a   )

     def 	SCREAMING_SNAKE_CASE__						(					self:str     ,		_a:int   ):
       return self.query(_a     ,		index + 1   )







     def 	SCREAMING_SNAKE_CASE__						(					self:str     ,		_a:int   ):
       value -= self.tree[0]
       if value < 0:
         return -1

       snake_case__						= 1  # Largest power of 2 <= size
       while j * 2 < self.size:
         j *= 2

       snake_case__						= 0

       while j > 0:
         if i + j < self.size and self.tree[i + j] <= value:
           value -= self.tree[i + j]
           i += j
         j //= 2
       return i


if __name__ == "__main__":
   import doctest

   doctest.testmod()

