





import itertools
import math




def    A_(			A   ):

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

	# All primes number are in format of 6k +/- 1
	for i in range(5				,      int(math.sqrt(A   ) + 1   )				,      6   ):
		if number % i == 0 or number % (i + 2) == 0:
			return False
	return True




def    A_(			):
	UpperCAmelCase_								=     2
	while True:
		if is_prime(A   ):
			yield num
		num += 1




def    A_(			A = 10001   ):
	return next(itertools.islice(prime_generator()				,      nth - 1				,      A   )   )


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









from math import factorial

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




def    A_(			A   ):
	if not isinstance(A				,      A   ):
		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(A   )   )




def    A_(			A = 60				,      A = 1000000   ):

	if not isinstance(A				,      A   ) or not isinstance(A				,      A   ):
		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
	UpperCAmelCase_								=     0
	# the cached sizes of the previous chains
	UpperCAmelCase_								=     {}

	for start_chain_element in range(1				,      A   ):
		# The temporary set will contain the elements of the chain
		UpperCAmelCase_								=     set()
		UpperCAmelCase_								=     0

		# Stop computing the chain when you find a cached size, a repeating item or the
		# length is greater then the desired one.
		UpperCAmelCase_								=     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(A   )
			chain_set_length += 1
			UpperCAmelCase_								=     digit_factorial_sum(A   )

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

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


