





'''simple docstring'''




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





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

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





def 	__lowerCamelCase			(      __lowerCAmelCase       :							int		)		->  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 < 10_00_00_00:
      snake_case 						=   number_chain
      number *= 10

   return number_chain





def 	__lowerCamelCase			(      __lowerCAmelCase       :							int = 10_00_00_00		)		->  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() = }""")








'''simple docstring'''




from __future__ import annotations





def 	__lowerCamelCase			(      __lowerCAmelCase       :							Any      ,    __lowerCAmelCase       :							str      ,    __lowerCAmelCase       :							Any      ,    __lowerCAmelCase       :							int		)		->  Tuple:  # noqa: E741
   while r - l > 1:
      snake_case 						=   (l + r) // 2
      if v[m] >= key:
         snake_case 						=   m
      else:
         snake_case 						=   m  # noqa: E741
   return r





def 	__lowerCamelCase			(      __lowerCAmelCase       :							list[int]		)		->  int:
   if len(__lowerCAmelCase		) == 0:
      return 0

   snake_case 						=   [0] * len(__lowerCAmelCase		)
   snake_case 						=   1

   snake_case 						=   v[0]

   for i in range(1      ,    len(__lowerCAmelCase		)		):
      if v[i] < tail[0]:
         snake_case 						=   v[i]
      elif v[i] > tail[length - 1]:
         snake_case 						=   v[i]
         length += 1
      else:
         snake_case 						=   v[i]

   return length


if __name__ == "__main__":
 import doctest

 doctest.testmod()

