
__lowerCAmelCase   :     List[str]      =						{
    "0": 1,
    "1": 1,
    "2": 2,
    "3": 6,
    "4": 24,
    "5": 120,
    "6": 720,
    "7": 5_040,
    "8": 40_320,
    "9": 362_880,
}

__lowerCAmelCase   :     List[str]      =						{145: 145}

__lowerCAmelCase   :     Optional[int]      =						{
    145: 0,
    169: 3,
    36_301: 3,
    1_454: 3,
    871: 2,
    45_361: 2,
    872: 2,
}


def       UpperCAmelCase_					(  __lowerCAmelCase		)	->  int:
    if n in CACHE_SUM_DIGIT_FACTORIALS:
        return CACHE_SUM_DIGIT_FACTORIALS[n]
    __lowercase						:     Union[str, Any]		       =    sum(DIGIT_FACTORIALS[let] for let in str(__lowerCAmelCase		)		)
    __lowercase						:     Any		       =    ret
    return ret


def       UpperCAmelCase_					(  __lowerCAmelCase		,   __lowerCAmelCase = None		)	->  int:
    __lowercase						:     List[Any]		       =    previous or set()
    if n in CHAIN_LENGTH_CACHE:
        return CHAIN_LENGTH_CACHE[n]
    __lowercase						:     List[str]		       =    sum_digit_factorials(__lowerCAmelCase		)
    if next_number in previous:
        __lowercase						:     Union[str, Any]		       =    0
        return 0
    else:
        previous.add(__lowerCAmelCase		)
        __lowercase						:     Union[str, Any]		       =    1 + chain_length(__lowerCAmelCase		,   __lowerCAmelCase		)
        __lowercase						:     int		       =    ret
        return ret


def       UpperCAmelCase_					(  __lowerCAmelCase = 60		,   __lowerCAmelCase = 1_000_000		)	->  int:
    return sum(1 for i in range(1		,   __lowerCAmelCase		) if chain_length(__lowerCAmelCase		) == num_terms		)


if __name__ == "__main__":
 print(F'{solution() = }')




from typing import TYPE_CHECKING

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


__lowerCAmelCase   :     Optional[int]      =						{"configuration_vit_hybrid": ["VIT_HYBRID_PRETRAINED_CONFIG_ARCHIVE_MAP", "ViTHybridConfig"]}

try:
 if not is_torch_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 __lowerCAmelCase   :     List[Any]      =						[
     "VIT_HYBRID_PRETRAINED_MODEL_ARCHIVE_LIST",
     "ViTHybridForImageClassification",
     "ViTHybridModel",
     "ViTHybridPreTrainedModel",
 ]

try:
 if not is_vision_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 __lowerCAmelCase   :     Tuple      =						["ViTHybridImageProcessor"]


if TYPE_CHECKING:
 from .configuration_vit_hybrid import VIT_HYBRID_PRETRAINED_CONFIG_ARCHIVE_MAP, ViTHybridConfig

 try:
  if not is_torch_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_vit_hybrid import (
      VIT_HYBRID_PRETRAINED_MODEL_ARCHIVE_LIST,
      ViTHybridForImageClassification,
      ViTHybridModel,
      ViTHybridPreTrainedModel,
  )

 try:
  if not is_vision_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .image_processing_vit_hybrid import ViTHybridImageProcessor


else:
 import sys

 __lowerCAmelCase   :     Tuple      =						_LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)


