



'''simple docstring'''



from math import factorial

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



def   __lowerCAmelCase					(							lowerCamelCase   :						int					):






	'''simple docstring'''




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



def   __lowerCAmelCase					(							lowerCamelCase   :						int = 60				,		lowerCamelCase   :						int = 1_00_00_00					):






	'''simple docstring'''




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

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

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

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

		__lowerCAmelCase												=  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 importlib
import os
from dataclasses import dataclass
from enum import Enum
from typing import Any, Dict, Optional, Union

import torch

from ..utils import BaseOutput


lowerCAmelCase	:		Optional[Any]				=   '''scheduler_config.json'''






class 					UpperCAmelCase__	(		UpperCamelCase__ ):
					a      :     str        =							1
					a      :     Optional[int]        =							2
					a      :     int        =							3
					a      :     Union[str, Any]        =							4
					a      :     int        =							5
					a      :     Optional[int]        =							6
					a      :     str        =							7
					a      :     List[Any]        =							8
					a      :     List[str]        =							9
					a      :     List[str]        =							1_0
					a      :     int        =							1_1
					a      :     Any        =							1_2
					a      :     Any        =							1_3
					a      :     Tuple        =							1_4






@dataclass
class 					UpperCAmelCase__	(		UpperCamelCase__ ):
					a      :     torch.FloatTensor






class 					UpperCAmelCase__	:
					a      :     Tuple        =							SCHEDULER_CONFIG_NAME
					a      :     Union[str, Any]        =							[]
					a      :     str        =							True



					@classmethod
					def        UpperCAmelCase_ (    cls			,				UpperCamelCase = None			,				UpperCamelCase = None			,				UpperCamelCase=False			,				**UpperCamelCase			,				)     ->			int:
						__lowerCAmelCase							,       __lowerCAmelCase							,       __lowerCAmelCase												=  cls.load_config(
						    pretrained_model_name_or_path=UpperCamelCase			,				subfolder=UpperCamelCase			,				return_unused_kwargs=UpperCamelCase			,				return_commit_hash=UpperCamelCase			,				**UpperCamelCase			,				)
						return cls.from_config(UpperCamelCase			,				return_unused_kwargs=UpperCamelCase			,				**UpperCamelCase     )



					def        UpperCAmelCase_ (    self			,				UpperCamelCase			,				UpperCamelCase = False			,				**UpperCamelCase     )     ->			Dict:
						self.save_config(save_directory=UpperCamelCase			,				push_to_hub=UpperCamelCase			,				**UpperCamelCase     )



					@property
					def        UpperCAmelCase_ (    self     )     ->			str:
						return self._get_compatibles()



					@classmethod
					def        UpperCAmelCase_ (    cls     )     ->			Tuple:
						__lowerCAmelCase												=  list(set([cls.__name__] + cls._compatibles     )     )
						__lowerCAmelCase												=  importlib.import_module(__name__.split("."     )[0]     )
						__lowerCAmelCase												=  [
						    getattr(UpperCamelCase			,				UpperCamelCase     ) for c in compatible_classes_str if hasattr(UpperCamelCase			,				UpperCamelCase     )
						]
						return compatible_classes