

from math import factorial

_SCREAMING_SNAKE_CASE    :      dict[str, int]          =			{str(digit): factorial(digit) for digit in range(1_0)}

def 				SCREAMING_SNAKE_CASE     (      __UpperCamelCase :						int       ) ->       int:

				"""simple docstring"""







				if not isinstance(__UpperCamelCase							,						__UpperCamelCase       ):
								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(__UpperCamelCase       )       )

def 				SCREAMING_SNAKE_CASE     (      __UpperCamelCase :						int = 60							,						__UpperCamelCase :						int = 1_00_00_00       ) ->       int:

				"""simple docstring"""







				if not isinstance(__UpperCamelCase							,						__UpperCamelCase       ) or not isinstance(__UpperCamelCase							,						__UpperCamelCase       ):
								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
				A__  :	List[Any]         =							0
				# the cached sizes of the previous chains
				A__  :	dict[int, int]         =							{}

				for start_chain_element in range(1							,						__UpperCamelCase       ):
								# The temporary set will contain the elements of the chain
								A__  :	List[Any]         =							set()
								A__  :	int         =							0

								# Stop computing the chain when you find a cached size, a repeating item or the
								# length is greater then the desired one.
								A__  :	Optional[int]         =							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(__UpperCamelCase       )
												chain_set_length += 1
												A__  :	List[str]         =							digit_factorial_sum(__UpperCamelCase       )

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

								A__  :	Dict         =							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()}""")

import json
import os
import tempfile

from transformers.testing_utils import check_json_file_has_correct_format







class  UpperCamelCase__		:







	'''simple docstring'''
	_lowerCAmelCase							       =				None





	def   __snake_case				(			self		):
					A__  :	Dict         =							self.feature_extraction_class(**self.feat_extract_dict		)
					A__  :	Tuple         =							json.loads(feat_extract.to_json_string()		)
					for key, value in self.feat_extract_dict.items():
									self.assertEqual(obj[key]				,       UpperCamelCase__		)





	def   __snake_case				(			self		):
					A__  :	Any         =							self.feature_extraction_class(**self.feat_extract_dict		)

					with tempfile.TemporaryDirectory() as tmpdirname:
									A__  :	Any         =							os.path.join(UpperCamelCase__				,       '''feat_extract.json'''		)
									feat_extract_first.to_json_file(UpperCamelCase__		)
									A__  :	Dict         =							self.feature_extraction_class.from_json_file(UpperCamelCase__		)

					self.assertEqual(feat_extract_second.to_dict()				,       feat_extract_first.to_dict()		)





	def   __snake_case				(			self		):
					A__  :	Any         =							self.feature_extraction_class(**self.feat_extract_dict		)

					with tempfile.TemporaryDirectory() as tmpdirname:
									A__  :	Any         =							feat_extract_first.save_pretrained(UpperCamelCase__		)[0]
									check_json_file_has_correct_format(UpperCamelCase__		)
									A__  :	Optional[int]         =							self.feature_extraction_class.from_pretrained(UpperCamelCase__		)

					self.assertEqual(feat_extract_second.to_dict()				,       feat_extract_first.to_dict()		)





	def   __snake_case				(			self		):
					A__  :	str         =							self.feature_extraction_class()
					self.assertIsNotNone(UpperCamelCase__		)