



snake_case     :    int						=    {
    '0': 1,
    '1': 1,
    '2': 2,
    '3': 6,
    '4': 2_4,
    '5': 1_2_0,
    '6': 7_2_0,
    '7': 5_0_4_0,
    '8': 4_0_3_2_0,
    '9': 3_6_2_8_8_0,
}

snake_case     :    Any						=    {1_4_5: 1_4_5}

snake_case     :    List[Any]						=    {
    1_4_5: 0,
    1_6_9: 3,
    3_6_3_0_1: 3,
    1_4_5_4: 3,
    8_7_1: 2,
    4_5_3_6_1: 2,
    8_7_2: 2,
}
def 						snake_case__							(       __lowercase							)		->		int:







						"""simple docstring"""

						if n in CACHE_SUM_DIGIT_FACTORIALS:
												return CACHE_SUM_DIGIT_FACTORIALS[n]
						A__						:				Optional[Any]         =			sum(DIGIT_FACTORIALS[let] for let in str(__lowercase							)							)
						A__						:				List[Any]         =			ret
						return ret
def 						snake_case__							(       __lowercase				,  __lowercase = None							)		->		int:







						"""simple docstring"""

						A__						:				Tuple         =			previous or set()
						if n in CHAIN_LENGTH_CACHE:
												return CHAIN_LENGTH_CACHE[n]
						A__						:				List[Any]         =			sum_digit_factorials(__lowercase							)
						if next_number in previous:
												A__						:				List[Any]         =			0
												return 0
						else:
												previous.add(__lowercase							)
												A__						:				List[str]         =			1 + chain_length(__lowercase				,  __lowercase							)
												A__						:				Union[str, Any]         =			ret
												return ret
def 						snake_case__							(       __lowercase = 6_0				,  __lowercase = 1_0_0_0_0_0_0							)		->		int:







						"""simple docstring"""

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


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




def 						snake_case__							(       __lowercase = 1_0_0_0							)		->		int:







						"""simple docstring"""

						A__						:				int         =			0
						A__						:				Optional[int]         =			0
						while 1:
												num += 3
												if num >= n:
																		break
												total += num
												num += 2
												if num >= n:
																		break
												total += num
												num += 1
												if num >= n:
																		break
												total += num
												num += 3
												if num >= n:
																		break
												total += num
												num += 1
												if num >= n:
																		break
												total += num
												num += 2
												if num >= n:
																		break
												total += num
												num += 3
												if num >= n:
																		break
												total += num
						return total


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