

from math import factorial

lowerCAmelCase_			      =      {str(digit): factorial(digit) for digit in range(10)}


def     __SCREAMING_SNAKE_CASE   (SCREAMING_SNAKE_CASE__			):
						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     __SCREAMING_SNAKE_CASE   (SCREAMING_SNAKE_CASE__ = 60    ,						SCREAMING_SNAKE_CASE__ = 1000000			):

						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
						snake_case_  =      0
						# the cached sizes of the previous chains
						snake_case_  =      {}

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

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

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

												snake_case_  =      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"""



from collections import defaultdict
from math import gcd







def 						__lowercase	(  snake_case_    :    int = 1500000		)  ->int:



    '''simple docstring'''







    __A       :		defaultdict							=	defaultdict(snake_case_		)
    __A       :		Any							=	2
    while 2 * euclid_m * (euclid_m + 1) <= limit:
        for euclid_n in range((euclid_m % 2) + 1							,snake_case_							,2		):
            if gcd(snake_case_							,snake_case_		) > 1:
                continue
            __A       :		List[Any]							=	2 * euclid_m * (euclid_m + euclid_n)
            for perimeter in range(snake_case_							,limit + 1							,snake_case_		):
                frequencies[perimeter] += 1
        euclid_m += 1
    return sum(1 for frequency in frequencies.values() if frequency == 1		)


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




