


'''simple docstring'''


from math import factorial

UpperCAmelCase_						:  dict[str, int]				  =						{str(digit): factorial(digit) for digit in range(10)}







def      snake_case_  (    SCREAMING_SNAKE_CASE__	):







				"""simple docstring"""





				if not isinstance(SCREAMING_SNAKE_CASE__				, SCREAMING_SNAKE_CASE__	):
								raise TypeError("""Parameter number must be int"""	)

				if number < 0:
								raise ValueError("""Parameter number must be greater than or equal to 0"""	)

				# Converts number in string to iterate on its digits and adds its factorial.
				return sum(DIGIT_FACTORIAL[digit] for digit in str(SCREAMING_SNAKE_CASE__	)	)







def      snake_case_  (    SCREAMING_SNAKE_CASE__ = 60				, SCREAMING_SNAKE_CASE__ = 100_0000	):







				"""simple docstring"""





				if not isinstance(SCREAMING_SNAKE_CASE__				, SCREAMING_SNAKE_CASE__	) or not isinstance(SCREAMING_SNAKE_CASE__				, SCREAMING_SNAKE_CASE__	):
								raise TypeError("""Parameters chain_length and number_limit must be int"""	)

				if chain_length <= 0 or number_limit <= 0:
								raise ValueError(
								    """Parameters chain_length and number_limit must be greater than 0"""	)

				# the counter for the chains with the exact desired length
				_SCREAMING_SNAKE_CASE					:			Tuple							= 0
				# the cached sizes of the previous chains
				_SCREAMING_SNAKE_CASE					:			dict[int, int]							= {}

				for start_chain_element in range(1				, SCREAMING_SNAKE_CASE__	):
								# The temporary set will contain the elements of the chain
								_SCREAMING_SNAKE_CASE					:			Dict							= set()
								_SCREAMING_SNAKE_CASE					:			str							= 0

								# Stop computing the chain when you find a cached size, a repeating item or the
								# length is greater then the desired one.
								_SCREAMING_SNAKE_CASE					:			Optional[Any]							= start_chain_element
								while (
								    chain_element not in chain_sets_lengths
								    and chain_element not in chain_set
								    and chain_set_length <= chain_length
								):
												chain_set.add(SCREAMING_SNAKE_CASE__	)
												chain_set_length += 1
												_SCREAMING_SNAKE_CASE					:			Union[str, Any]							= digit_factorial_sum(SCREAMING_SNAKE_CASE__	)

								if chain_element in chain_sets_lengths:
												chain_set_length += chain_sets_lengths[chain_element]

								_SCREAMING_SNAKE_CASE					:			List[Any]							= chain_set_length

								# If chain contains the exact amount of elements increase the counter
								if chain_set_length == chain_length:
												chains_counter += 1

				return chains_counter


if __name__ == "__main__":
				import doctest

				doctest.testmod()
				print(F"{solution()}")








'''simple docstring'''


import math







def      snake_case_  (    SCREAMING_SNAKE_CASE__	):







				"""simple docstring"""





				assert isinstance(SCREAMING_SNAKE_CASE__				, SCREAMING_SNAKE_CASE__	) and (
				    number >= 0
				), "'number' must been an int and positive"

				if 1 < number < 4:
								# 2 and 3 are primes
								return True
				elif number < 2 or not number % 2:
								# Negatives, 0, 1 and all even numbers are not primes
								return False

				_SCREAMING_SNAKE_CASE					:			List[str]							= range(3				, int(math.sqrt(SCREAMING_SNAKE_CASE__	) + 1	)				, 2	)
				return not any(not number % i for i in odd_numbers	)







def      snake_case_  (    SCREAMING_SNAKE_CASE__				, SCREAMING_SNAKE_CASE__=1				, **SCREAMING_SNAKE_CASE__	):







				"""simple docstring"""





				_SCREAMING_SNAKE_CASE					:			Dict							= factor * value
				_SCREAMING_SNAKE_CASE					:			Optional[Any]							= value

				while not is_prime(SCREAMING_SNAKE_CASE__	):
								value += 1 if not ("desc" in kwargs and kwargs["desc"] is True) else -1

				if value == first_value_val:
								return next_prime(value + 1				, **SCREAMING_SNAKE_CASE__	)
				return value




