lowercase_  							=			{
    "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,
}

lowercase_  							=			{1_45: 1_45}

lowercase_  							=			{
    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				(		__SCREAMING_SNAKE_CASE       :					int   ):







    '''simple docstring'''
    if n in CACHE_SUM_DIGIT_FACTORIALS:
        return CACHE_SUM_DIGIT_FACTORIALS[n]
    __snake_case       :				Any 			=    sum(DIGIT_FACTORIALS[let] for let in str(__SCREAMING_SNAKE_CASE   )   )
    __snake_case       :				List[Any] 			=    ret
    return ret







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







    '''simple docstring'''
    __snake_case       :				str 			=    previous or set()
    if n in CHAIN_LENGTH_CACHE:
        return CHAIN_LENGTH_CACHE[n]
    __snake_case       :				Any 			=    sum_digit_factorials(__SCREAMING_SNAKE_CASE   )
    if next_number in previous:
        __snake_case       :				Union[str, Any] 			=    0
        return 0
    else:
        previous.add(__SCREAMING_SNAKE_CASE   )
        __snake_case       :				Dict 			=    1 + chain_length(__SCREAMING_SNAKE_CASE		,							__SCREAMING_SNAKE_CASE   )
        __snake_case       :				str 			=    ret
        return ret







def 					__lowerCAmelCase				(		__SCREAMING_SNAKE_CASE       :					int = 6_0		,							__SCREAMING_SNAKE_CASE       :					int = 1_0_0_0_0_0_0   ):







    '''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() = }''')




import math
from timeit import timeit







def 					__lowerCAmelCase				(		__SCREAMING_SNAKE_CASE       :					int   ):







    '''simple docstring'''
    __snake_case       :				Optional[Any] 			=    0
    __snake_case       :				Union[str, Any] 			=    abs(__SCREAMING_SNAKE_CASE   )
    while True:
        __snake_case       :				List[str] 			=    n // 1_0
        digits += 1
        if n == 0:
            break
    return digits







def 					__lowerCAmelCase				(		__SCREAMING_SNAKE_CASE       :					int   ):







    '''simple docstring'''
    return 1 if n == 0 else math.floor(math.log(abs(__SCREAMING_SNAKE_CASE   )		,							1_0   ) + 1   )







def 					__lowerCAmelCase				(		__SCREAMING_SNAKE_CASE       :					int   ):







    '''simple docstring'''
    return len(str(abs(__SCREAMING_SNAKE_CASE   )   )   )







def 					__lowerCAmelCase				(		):







    '''simple docstring'''
    from collections.abc import Callable

    def benchmark_a_function(__SCREAMING_SNAKE_CASE       :					Callable		,							__SCREAMING_SNAKE_CASE       :					int   ) -> None:
        __snake_case       :				Tuple 			=    F'''{func.__name__}({value})'''
        __snake_case       :				Union[str, Any] 			=    timeit(F'''__main__.{call}'''		,							setup="""import __main__"""   )
        print(F'''{call}: {func(__SCREAMING_SNAKE_CASE   )} -- {timing} seconds'''   )

    for value in (2_6_2_1_4_4, 1_1_2_5_8_9_9_9_0_6_8_4_2_6_2_4, 1_2_6_7_6_5_0_6_0_0_2_2_8_2_2_9_4_0_1_4_9_6_7_0_3_2_0_5_3_7_6):
        for func in (num_digits, num_digits_fast, num_digits_faster):
            benchmark_a_function(__SCREAMING_SNAKE_CASE		,							__SCREAMING_SNAKE_CASE   )
        print()


if __name__ == "__main__":
     import doctest

     doctest.testmod()
     benchmark()



