



UpperCamelCase_									=   {
    '''0''': 1,
    '''1''': 1,
    '''2''': 2,
    '''3''': 6,
    '''4''': 24,
    '''5''': 120,
    '''6''': 720,
    '''7''': 5040,
    '''8''': 40320,
    '''9''': 362880,
}

UpperCamelCase_									=   {145: 145}

UpperCamelCase_									=   {
    145: 0,
    169: 3,
    36301: 3,
    1454: 3,
    871: 2,
    45361: 2,
    872: 2,
}







def       lowerCamelCase_  (    _a       :						int    ):



    '''simple docstring'''




    if n in CACHE_SUM_DIGIT_FACTORIALS:
        return CACHE_SUM_DIGIT_FACTORIALS[n]
    UpperCAmelCase_     :       Union[str, Any]  		=					sum(DIGIT_FACTORIALS[let] for let in str(_a    )    )
    UpperCAmelCase_     :       Any  		=					ret
    return ret







def       lowerCamelCase_  (    _a       :						int   ,		_a       :						set | None = None    ):



    '''simple docstring'''




    UpperCAmelCase_     :       Dict  		=					previous or set()
    if n in CHAIN_LENGTH_CACHE:
        return CHAIN_LENGTH_CACHE[n]
    UpperCAmelCase_     :       List[Any]  		=					sum_digit_factorials(_a    )
    if next_number in previous:
        UpperCAmelCase_     :       int  		=					0
        return 0
    else:
        previous.add(_a    )
        UpperCAmelCase_     :       Optional[Any]  		=					1 + chain_length(_a   ,		_a    )
        UpperCAmelCase_     :       Any  		=					ret
        return ret







def       lowerCamelCase_  (    _a       :						int = 60   ,		_a       :						int = 100_0000    ):



    '''simple docstring'''




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


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




from ..utils import DummyObject, requires_backends

class      __snake_case				(   metaclass=_UpperCAmelCase):
					SCREAMING_SNAKE_CASE_		:       str								=			["torch", "transformers", "k_diffusion"]
					def __init__(						self       :						Tuple	,      *_lowerCAmelCase       :						Union[str, Any]	,      **_lowerCAmelCase       :						Union[str, Any]  )							->					Dict:



											'''simple docstring'''





											requires_backends(self	,      ['torch', 'transformers', 'k_diffusion']  )
					@classmethod
					def 	a			(						cls       :						Optional[int]	,      *_lowerCAmelCase       :						Any	,      **_lowerCAmelCase       :						Optional[Any]  )							->					Optional[Any]:



											'''simple docstring'''





											requires_backends(cls	,      ['torch', 'transformers', 'k_diffusion']  )







					@classmethod
					def 	a			(						cls       :						Union[str, Any]	,      *_lowerCAmelCase       :						Tuple	,      **_lowerCAmelCase       :						str  )							->					Tuple:



											'''simple docstring'''





											requires_backends(cls	,      ['torch', 'transformers', 'k_diffusion']  )

