



from math import factorial

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






def     __a					(		__UpperCAmelCase       ):
 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     __a					(		__UpperCAmelCase = 60							,  __UpperCAmelCase = 100_0000       ):

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

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

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

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

  a__												= 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 unittest

import torch
from torch import nn

from diffusers.models.activations import get_activation







class        UpperCAmelCase_			(			unittest.TestCase      ):
    """simple docstring"""







    def lowerCamelCase			(       self   :	Union[str, Any]		):
          snake_case__    :       int       		= get_activation("""swish"""		)

          self.assertIsInstance(snake_case_					,	nn.SiLU		)

          self.assertEqual(act(torch.tensor(-100					,	dtype=torch.floataa		)		).item()					,	0		)
          self.assertNotEqual(act(torch.tensor(-1					,	dtype=torch.floataa		)		).item()					,	0		)
          self.assertEqual(act(torch.tensor(0					,	dtype=torch.floataa		)		).item()					,	0		)
          self.assertEqual(act(torch.tensor(20					,	dtype=torch.floataa		)		).item()					,	20		)




    def lowerCamelCase			(       self   :	Optional[Any]		):
          snake_case__    :       int       		= get_activation("""silu"""		)

          self.assertIsInstance(snake_case_					,	nn.SiLU		)

          self.assertEqual(act(torch.tensor(-100					,	dtype=torch.floataa		)		).item()					,	0		)
          self.assertNotEqual(act(torch.tensor(-1					,	dtype=torch.floataa		)		).item()					,	0		)
          self.assertEqual(act(torch.tensor(0					,	dtype=torch.floataa		)		).item()					,	0		)
          self.assertEqual(act(torch.tensor(20					,	dtype=torch.floataa		)		).item()					,	20		)




    def lowerCamelCase			(       self   :	Dict		):
          snake_case__    :       Union[str, Any]       		= get_activation("""mish"""		)

          self.assertIsInstance(snake_case_					,	nn.Mish		)

          self.assertEqual(act(torch.tensor(-200					,	dtype=torch.floataa		)		).item()					,	0		)
          self.assertNotEqual(act(torch.tensor(-1					,	dtype=torch.floataa		)		).item()					,	0		)
          self.assertEqual(act(torch.tensor(0					,	dtype=torch.floataa		)		).item()					,	0		)
          self.assertEqual(act(torch.tensor(20					,	dtype=torch.floataa		)		).item()					,	20		)




    def lowerCamelCase			(       self   :	Union[str, Any]		):
          snake_case__    :       int       		= get_activation("""gelu"""		)

          self.assertIsInstance(snake_case_					,	nn.GELU		)

          self.assertEqual(act(torch.tensor(-100					,	dtype=torch.floataa		)		).item()					,	0		)
          self.assertNotEqual(act(torch.tensor(-1					,	dtype=torch.floataa		)		).item()					,	0		)
          self.assertEqual(act(torch.tensor(0					,	dtype=torch.floataa		)		).item()					,	0		)
          self.assertEqual(act(torch.tensor(20					,	dtype=torch.floataa		)		).item()					,	20		)
