






UpperCamelCase__  :					Optional[Any]  						=    {
    """0""": 1,
    """1""": 1,
    """2""": 2,
    """3""": 6,
    """4""": 24,
    """5""": 120,
    """6""": 720,
    """7""": 5_040,
    """8""": 40_320,
    """9""": 362_880,
}

UpperCamelCase__  :					Union[str, Any]  						=    {145: 145}

UpperCamelCase__  :					List[Any]  						=    {
    145: 0,
    169: 3,
    36_301: 3,
    1_454: 3,
    871: 2,
    45_361: 2,
    872: 2,
}





def      SCREAMING_SNAKE_CASE__  (      snake_case_     )      ->     Tuple:


	"""simple docstring"""



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





def      SCREAMING_SNAKE_CASE__  (      snake_case_,     snake_case_ = None     )      ->     List[Any]:


	"""simple docstring"""



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





def      SCREAMING_SNAKE_CASE__  (      snake_case_ = 6_0,     snake_case_ = 1_0_0_0_0_0_0     )      ->     Any:


	"""simple docstring"""



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


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












from itertools import permutations






def 			lowerCamelCase__	():
     _SCREAMING_SNAKE_CASE				:		Dict  			=							list(map("".join,				permutations("0123456789"		)		)		)
     return result[999999]


if __name__ == "__main__":
       print(solution())