
'''simple docstring'''



UpperCamelCase__ :						Optional[Any]    							=					{
    "0": 1,
    "1": 1,
    "2": 2,
    "3": 6,
    "4": 24,
    "5": 120,
    "6": 720,
    "7": 5_040,
    "8": 40_320,
    "9": 362_880,
}

UpperCamelCase__ :						Optional[Any]    							=					{145: 145}

UpperCamelCase__ :						Dict    							=					{
    145: 0,
    169: 3,
    36_301: 3,
    1_454: 3,
    871: 2,
    45_361: 2,
    872: 2,
}
def 				lowerCAmelCase_		(			SCREAMING_SNAKE_CASE_  )       ->       int:




   """simple docstring"""
   if n in CACHE_SUM_DIGIT_FACTORIALS:
      return CACHE_SUM_DIGIT_FACTORIALS[n]
   _SCREAMING_SNAKE_CASE       	=			sum(DIGIT_FACTORIALS[let] for let in str(SCREAMING_SNAKE_CASE_  )  )
   _SCREAMING_SNAKE_CASE       	=			ret
   return ret
def 				lowerCAmelCase_		(			SCREAMING_SNAKE_CASE_      , SCREAMING_SNAKE_CASE_ = None  )       ->       int:




   """simple docstring"""
   _SCREAMING_SNAKE_CASE       	=			previous or set()
   if n in CHAIN_LENGTH_CACHE:
      return CHAIN_LENGTH_CACHE[n]
   _SCREAMING_SNAKE_CASE       	=			sum_digit_factorials(SCREAMING_SNAKE_CASE_  )
   if next_number in previous:
      _SCREAMING_SNAKE_CASE       	=			0
      return 0
   else:
      previous.add(SCREAMING_SNAKE_CASE_  )
      _SCREAMING_SNAKE_CASE       	=			1 + chain_length(SCREAMING_SNAKE_CASE_      , SCREAMING_SNAKE_CASE_  )
      _SCREAMING_SNAKE_CASE       	=			ret
      return ret
def 				lowerCAmelCase_		(			SCREAMING_SNAKE_CASE_ = 60      , SCREAMING_SNAKE_CASE_ = 1_00_00_00  )       ->       int:




   """simple docstring"""
   return sum(1 for i in range(1      , SCREAMING_SNAKE_CASE_  ) if chain_length(SCREAMING_SNAKE_CASE_  ) == num_terms  )


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








'''simple docstring'''



from typing import TYPE_CHECKING

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


UpperCamelCase__ :						List[str]    							=					{"configuration_gptj": ["GPTJ_PRETRAINED_CONFIG_ARCHIVE_MAP", "GPTJConfig", "GPTJOnnxConfig"]}

try:
     if not is_torch_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     UpperCamelCase__ :						Optional[Any]    							=					[
         "GPTJ_PRETRAINED_MODEL_ARCHIVE_LIST",
         "GPTJForCausalLM",
         "GPTJForQuestionAnswering",
         "GPTJForSequenceClassification",
         "GPTJModel",
         "GPTJPreTrainedModel",
     ]

try:
     if not is_tf_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     UpperCamelCase__ :						List[str]    							=					[
         "TFGPTJForCausalLM",
         "TFGPTJForQuestionAnswering",
         "TFGPTJForSequenceClassification",
         "TFGPTJModel",
         "TFGPTJPreTrainedModel",
     ]

try:
     if not is_flax_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     UpperCamelCase__ :						List[Any]    							=					[
         "FlaxGPTJForCausalLM",
         "FlaxGPTJModel",
         "FlaxGPTJPreTrainedModel",
     ]


if TYPE_CHECKING:
     from .configuration_gptj import GPTJ_PRETRAINED_CONFIG_ARCHIVE_MAP, GPTJConfig, GPTJOnnxConfig

     try:
          if not is_torch_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .modeling_gptj import (
              GPTJ_PRETRAINED_MODEL_ARCHIVE_LIST,
              GPTJForCausalLM,
              GPTJForQuestionAnswering,
              GPTJForSequenceClassification,
              GPTJModel,
              GPTJPreTrainedModel,
          )

     try:
          if not is_tf_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .modeling_tf_gptj import (
              TFGPTJForCausalLM,
              TFGPTJForQuestionAnswering,
              TFGPTJForSequenceClassification,
              TFGPTJModel,
              TFGPTJPreTrainedModel,
          )

     try:
          if not is_flax_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .modeling_flax_gptj import FlaxGPTJForCausalLM, FlaxGPTJModel, FlaxGPTJPreTrainedModel

else:
     import sys

     UpperCamelCase__ :						Any    							=					_LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)






