"""simple docstring"""

__lowercase    =				{
    '''0''': 1,
    '''1''': 1,
    '''2''': 2,
    '''3''': 6,
    '''4''': 24,
    '''5''': 120,
    '''6''': 720,
    '''7''': 5_040,
    '''8''': 40_320,
    '''9''': 362_880,
}

__lowercase    =				{145: 145}

__lowercase    =				{
    145: 0,
    169: 3,
    36_301: 3,
    1_454: 3,
    871: 2,
    45_361: 2,
    872: 2,
}


def    lowerCAmelCase			(__UpperCamelCase							:    str			):
							"""simple docstring"""


							if n in CACHE_SUM_DIGIT_FACTORIALS:
														return CACHE_SUM_DIGIT_FACTORIALS[n]
							__UpperCamelCase							=sum(DIGIT_FACTORIALS[let] for let in str(__UpperCamelCase			)			)
							__UpperCamelCase							=ret
							return ret


def    lowerCAmelCase			(__UpperCamelCase							:    List[Any]							,					__UpperCamelCase							:    Optional[Any] = None			):
							"""simple docstring"""


							__UpperCamelCase							=previous or set()
							if n in CHAIN_LENGTH_CACHE:
														return CHAIN_LENGTH_CACHE[n]
							__UpperCamelCase							=sum_digit_factorials(__UpperCamelCase			)
							if next_number in previous:
														__UpperCamelCase							=0
														return 0
							else:
														previous.add(__UpperCamelCase			)
														__UpperCamelCase							=1 + chain_length(__UpperCamelCase							,					__UpperCamelCase			)
														__UpperCamelCase							=ret
														return ret


def    lowerCAmelCase			(__UpperCamelCase							:    Dict = 6_0							,					__UpperCamelCase							:    Dict = 1_0_0_0_0_0_0			):
							"""simple docstring"""


							return sum(1 for i in range(1							,					__UpperCamelCase			) if chain_length(__UpperCamelCase			) == num_terms			)


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





"""simple docstring"""






from typing import TYPE_CHECKING

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


UpperCamelCase_						   =   {
    'configuration_mobilevitv2': [
        'MOBILEVITV2_PRETRAINED_CONFIG_ARCHIVE_MAP',
        'MobileViTV2Config',
        'MobileViTV2OnnxConfig',
    ],
}


try:
      if not is_torch_available():
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      pass
else:
      UpperCamelCase_						   =   [
          'MOBILEVITV2_PRETRAINED_MODEL_ARCHIVE_LIST',
          'MobileViTV2ForImageClassification',
          'MobileViTV2ForSemanticSegmentation',
          'MobileViTV2Model',
          'MobileViTV2PreTrainedModel',
      ]

if TYPE_CHECKING:
      from .configuration_mobilevitva import (
          MOBILEVITV2_PRETRAINED_CONFIG_ARCHIVE_MAP,
          MobileViTVaConfig,
          MobileViTVaOnnxConfig,
      )

      try:
            if not is_torch_available():
                  raise OptionalDependencyNotAvailable()
      except OptionalDependencyNotAvailable:
            pass
      else:
            from .modeling_mobilevitva import (
                MOBILEVITV2_PRETRAINED_MODEL_ARCHIVE_LIST,
                MobileViTVaForImageClassification,
                MobileViTVaForSemanticSegmentation,
                MobileViTVaModel,
                MobileViTVaPreTrainedModel,
            )

else:
      import sys

      UpperCamelCase_						   =   _LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)