






'''simple docstring'''




from math import factorial

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

def 					__lowercase						(			__lowercase       )       ->						int:

      '''simple docstring'''


      if not isinstance(__lowercase   ,  __lowercase       ):
            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(__lowercase       )       )

def 					__lowercase						(			__lowercase = 60   ,  __lowercase = 100_0000       )       ->						int:

      '''simple docstring'''


      if not isinstance(__lowercase   ,  __lowercase       ) or not isinstance(__lowercase   ,  __lowercase       ):
            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   ,  __lowercase       ):
            # 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(__lowercase       )
                  chain_set_length += 1
                  _A			     =	digit_factorial_sum(__lowercase       )

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




# Copyright 2021 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from argparse import ArgumentParser

from accelerate.commands.config import get_config_parser
from accelerate.commands.env import env_command_parser
from accelerate.commands.launch import launch_command_parser
from accelerate.commands.test import test_command_parser
from accelerate.commands.tpu import tpu_command_parser






def       _SCREAMING_SNAKE_CASE		(	) ->Dict:






	'''simple docstring'''






	a      :		Any	=				ArgumentParser("Accelerate CLI tool"    ,       usage="accelerate <command> [<args>]"    ,       allow_abbrev=_lowercase					)
	a      :		List[Any]	=				parser.add_subparsers(help="accelerate command helpers"					)

	# Register commands
	get_config_parser(subparsers=_lowercase					)
	env_command_parser(subparsers=_lowercase					)
	launch_command_parser(subparsers=_lowercase					)
	tpu_command_parser(subparsers=_lowercase					)
	test_command_parser(subparsers=_lowercase					)

	# Let's go
	a      :		List[Any]	=				parser.parse_args()

	if not hasattr(_lowercase    ,       "func"					):
		parser.print_help()
		exit(1					)

	# Run
	args.func(_lowercase					)


if __name__ == "__main__":
		main()


