
_A       =					{
    "0": 1,
    "1": 1,
    "2": 2,
    "3": 6,
    "4": 24,
    "5": 1_20,
    "6": 7_20,
    "7": 50_40,
    "8": 4_03_20,
    "9": 36_28_80,
}

_A       =					{1_45: 1_45}

_A       =					{
    1_45: 0,
    1_69: 3,
    3_63_01: 3,
    14_54: 3,
    8_71: 2,
    4_53_61: 2,
    8_72: 2,
}






def        lowerCamelCase__    (    __lowerCAmelCase  :  int    ):




			"""simple docstring"""


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






def        lowerCamelCase__    (    __lowerCAmelCase  :  int   ,							__lowerCAmelCase  :  set | None = None    ):




			"""simple docstring"""


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






def        lowerCamelCase__    (    __lowerCAmelCase  :  int = 60   ,							__lowerCAmelCase  :  int = 1000000    ):




			"""simple docstring"""


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


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





from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


_A       =					{"configuration_nat": ["NAT_PRETRAINED_CONFIG_ARCHIVE_MAP", "NatConfig"]}


try:
			if not is_torch_available():
						raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
			pass
else:
			_A       =					[
			    "NAT_PRETRAINED_MODEL_ARCHIVE_LIST",
			    "NatForImageClassification",
			    "NatModel",
			    "NatPreTrainedModel",
			    "NatBackbone",
			]

if TYPE_CHECKING:
			from .configuration_nat import NAT_PRETRAINED_CONFIG_ARCHIVE_MAP, NatConfig

			try:
						if not is_torch_available():
									raise OptionalDependencyNotAvailable()
			except OptionalDependencyNotAvailable:
						pass
			else:
						from .modeling_nat import (
						    NAT_PRETRAINED_MODEL_ARCHIVE_LIST,
						    NatBackbone,
						    NatForImageClassification,
						    NatModel,
						    NatPreTrainedModel,
						)

else:
			import sys

			_A       =					_LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)



