




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



def       UpperCAmelCase__  (     lowerCamelCase   ):
  lowercase    :List[Any]      	=						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
_UpperCAmelCase	:						list[bool | None]			=     [None] * 10000000
_UpperCAmelCase	:						Tuple			=     True
_UpperCAmelCase	:						List[str]			=     False



def       UpperCAmelCase__  (     lowerCamelCase   ):

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

  lowercase    :Optional[int]      	=						chain(next_number(__A   )   )
  lowercase    :int      	=						number_chain

  while number < 10000000:
    lowercase    :Dict      	=						number_chain
    number *= 10

  return number_chain



def       UpperCAmelCase__  (     lowerCamelCase = 10000000   ):
  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() = }''')









from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available


_UpperCAmelCase	:						Optional[int]			=     {
    "configuration_biogpt": ["BIOGPT_PRETRAINED_CONFIG_ARCHIVE_MAP", "BioGptConfig"],
    "tokenization_biogpt": ["BioGptTokenizer"],
}

try:
     if not is_torch_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     _UpperCAmelCase	:						int			=     [
         "BIOGPT_PRETRAINED_MODEL_ARCHIVE_LIST",
         "BioGptForCausalLM",
         "BioGptForTokenClassification",
         "BioGptForSequenceClassification",
         "BioGptModel",
         "BioGptPreTrainedModel",
     ]


if TYPE_CHECKING:
     from .configuration_biogpt import BIOGPT_PRETRAINED_CONFIG_ARCHIVE_MAP, BioGptConfig
     from .tokenization_biogpt import BioGptTokenizer

     try:
          if not is_torch_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .modeling_biogpt import (
              BIOGPT_PRETRAINED_MODEL_ARCHIVE_LIST,
              BioGptForCausalLM,
              BioGptForSequenceClassification,
              BioGptForTokenClassification,
              BioGptModel,
              BioGptPreTrainedModel,
          )


else:
     import sys

     _UpperCAmelCase	:						Optional[Any]			=     _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)



