




'''simple docstring'''







from math import factorial

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







def 						_A      ( UpperCAmelCase						):






   '''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 						_A      ( UpperCAmelCase = 60      ,UpperCAmelCase = 1000000						):






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

   for start_chain_element in range(1      ,UpperCAmelCase						):
      # 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(UpperCAmelCase						)
         chain_set_length += 1
         A__       =     digit_factorial_sum(UpperCAmelCase						)

      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'''







from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_flax_available,
    is_tf_available,
    is_torch_available,
)


lowerCAmelCase_     						=				{
    '''configuration_roberta_prelayernorm''': [
        '''ROBERTA_PRELAYERNORM_PRETRAINED_CONFIG_ARCHIVE_MAP''',
        '''RobertaPreLayerNormConfig''',
        '''RobertaPreLayerNormOnnxConfig''',
    ],
}

try:
    if not is_torch_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    lowerCAmelCase_     						=				[
        '''ROBERTA_PRELAYERNORM_PRETRAINED_MODEL_ARCHIVE_LIST''',
        '''RobertaPreLayerNormForCausalLM''',
        '''RobertaPreLayerNormForMaskedLM''',
        '''RobertaPreLayerNormForMultipleChoice''',
        '''RobertaPreLayerNormForQuestionAnswering''',
        '''RobertaPreLayerNormForSequenceClassification''',
        '''RobertaPreLayerNormForTokenClassification''',
        '''RobertaPreLayerNormModel''',
        '''RobertaPreLayerNormPreTrainedModel''',
    ]

try:
    if not is_tf_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    lowerCAmelCase_     						=				[
        '''TF_ROBERTA_PRELAYERNORM_PRETRAINED_MODEL_ARCHIVE_LIST''',
        '''TFRobertaPreLayerNormForCausalLM''',
        '''TFRobertaPreLayerNormForMaskedLM''',
        '''TFRobertaPreLayerNormForMultipleChoice''',
        '''TFRobertaPreLayerNormForQuestionAnswering''',
        '''TFRobertaPreLayerNormForSequenceClassification''',
        '''TFRobertaPreLayerNormForTokenClassification''',
        '''TFRobertaPreLayerNormMainLayer''',
        '''TFRobertaPreLayerNormModel''',
        '''TFRobertaPreLayerNormPreTrainedModel''',
    ]

try:
    if not is_flax_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    lowerCAmelCase_     						=				[
        '''FlaxRobertaPreLayerNormForCausalLM''',
        '''FlaxRobertaPreLayerNormForMaskedLM''',
        '''FlaxRobertaPreLayerNormForMultipleChoice''',
        '''FlaxRobertaPreLayerNormForQuestionAnswering''',
        '''FlaxRobertaPreLayerNormForSequenceClassification''',
        '''FlaxRobertaPreLayerNormForTokenClassification''',
        '''FlaxRobertaPreLayerNormModel''',
        '''FlaxRobertaPreLayerNormPreTrainedModel''',
    ]


if TYPE_CHECKING:
    from .configuration_roberta_prelayernorm import (
        ROBERTA_PRELAYERNORM_PRETRAINED_CONFIG_ARCHIVE_MAP,
        RobertaPreLayerNormConfig,
        RobertaPreLayerNormOnnxConfig,
    )

    try:
        if not is_torch_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .modeling_roberta_prelayernorm import (
            ROBERTA_PRELAYERNORM_PRETRAINED_MODEL_ARCHIVE_LIST,
            RobertaPreLayerNormForCausalLM,
            RobertaPreLayerNormForMaskedLM,
            RobertaPreLayerNormForMultipleChoice,
            RobertaPreLayerNormForQuestionAnswering,
            RobertaPreLayerNormForSequenceClassification,
            RobertaPreLayerNormForTokenClassification,
            RobertaPreLayerNormModel,
            RobertaPreLayerNormPreTrainedModel,
        )

    try:
        if not is_tf_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .modeling_tf_roberta_prelayernorm import (
            TF_ROBERTA_PRELAYERNORM_PRETRAINED_MODEL_ARCHIVE_LIST,
            TFRobertaPreLayerNormForCausalLM,
            TFRobertaPreLayerNormForMaskedLM,
            TFRobertaPreLayerNormForMultipleChoice,
            TFRobertaPreLayerNormForQuestionAnswering,
            TFRobertaPreLayerNormForSequenceClassification,
            TFRobertaPreLayerNormForTokenClassification,
            TFRobertaPreLayerNormMainLayer,
            TFRobertaPreLayerNormModel,
            TFRobertaPreLayerNormPreTrainedModel,
        )

    try:
        if not is_flax_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .modeling_flax_roberta_prelayernorm import (
            FlaxRobertaPreLayerNormForCausalLM,
            FlaxRobertaPreLayerNormForMaskedLM,
            FlaxRobertaPreLayerNormForMultipleChoice,
            FlaxRobertaPreLayerNormForQuestionAnswering,
            FlaxRobertaPreLayerNormForSequenceClassification,
            FlaxRobertaPreLayerNormForTokenClassification,
            FlaxRobertaPreLayerNormModel,
            FlaxRobertaPreLayerNormPreTrainedModel,
        )

else:
    import sys

    lowerCAmelCase_     						=				_LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)


