



"""simple docstring"""







from math import factorial

lowercase__		:    Tuple				   =     {str(digit): factorial(digit) for digit in range(1_0)}

def     UpperCamelCase_   (   lowerCAmelCase__				:    List[Any]						)						->       List[Any]:

  """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     UpperCamelCase_   (   lowerCAmelCase__				:    List[str] = 60   ,       lowerCAmelCase__				:    List[str] = 100_0000						)						->       Optional[Any]:

  """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_       :    str								=			0
  # the cached sizes of the previous chains
  lowerCAmelCase_       :    dict[int, int]								=			{}

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

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

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

    lowerCAmelCase_       :    str								=			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 logging

from transformers.configuration_utils import PretrainedConfig


lowercase__		:    List[Any]				   =     logging.getLogger(__name__)







class 				UpperCamelCase__       (     lowercase_  ):




      """simple docstring"""




      _SCREAMING_SNAKE_CASE      =					"""masked_bert"""



      def __init__(				self    :				Any   ,      SCREAMING_SNAKE_CASE_    :				Union[str, Any]=3_0_5_2_2   ,      SCREAMING_SNAKE_CASE_    :				int=7_6_8   ,      SCREAMING_SNAKE_CASE_    :				Tuple=1_2   ,      SCREAMING_SNAKE_CASE_    :				List[Any]=1_2   ,      SCREAMING_SNAKE_CASE_    :				Tuple=3_0_7_2   ,      SCREAMING_SNAKE_CASE_    :				List[str]="gelu"   ,      SCREAMING_SNAKE_CASE_    :				Tuple=0.1   ,      SCREAMING_SNAKE_CASE_    :				List[Any]=0.1   ,      SCREAMING_SNAKE_CASE_    :				List[Any]=5_1_2   ,      SCREAMING_SNAKE_CASE_    :				Optional[Any]=2   ,      SCREAMING_SNAKE_CASE_    :				Dict=0.02   ,      SCREAMING_SNAKE_CASE_    :				Any=1E-12   ,      SCREAMING_SNAKE_CASE_    :				List[str]=0   ,      SCREAMING_SNAKE_CASE_    :				Optional[int]="topK"   ,      SCREAMING_SNAKE_CASE_    :				Optional[int]="constant"   ,      SCREAMING_SNAKE_CASE_    :				Union[str, Any]=0.0   ,      **SCREAMING_SNAKE_CASE_    :				Any   ,      ):
        super().__init__(pad_token_id=SCREAMING_SNAKE_CASE_   ,      **SCREAMING_SNAKE_CASE_	)

        lowerCAmelCase_       :    List[Any]								=			vocab_size
        lowerCAmelCase_       :    str								=			hidden_size
        lowerCAmelCase_       :    Optional[int]								=			num_hidden_layers
        lowerCAmelCase_       :    Dict								=			num_attention_heads
        lowerCAmelCase_       :    List[str]								=			hidden_act
        lowerCAmelCase_       :    List[Any]								=			intermediate_size
        lowerCAmelCase_       :    Any								=			hidden_dropout_prob
        lowerCAmelCase_       :    str								=			attention_probs_dropout_prob
        lowerCAmelCase_       :    Any								=			max_position_embeddings
        lowerCAmelCase_       :    Dict								=			type_vocab_size
        lowerCAmelCase_       :    Tuple								=			initializer_range
        lowerCAmelCase_       :    List[Any]								=			layer_norm_eps
        lowerCAmelCase_       :    str								=			pruning_method
        lowerCAmelCase_       :    Optional[Any]								=			mask_init
        lowerCAmelCase_       :    int								=			mask_scale





