
"""simple docstring"""





from __future__ import annotations

_a									=				'Alexander Joslin'







def       __a	(						__lowerCamelCase    ):

   if number <= 0:
      UpperCAmelCase_   :   Optional[Any]     	=       f"""n must be greater than 0. Got n = {number}"""
      raise ValueError(__lowerCamelCase    )

   UpperCAmelCase_   :   Optional[Any]     	=       [number + 1] * (number + 1)

   # starting position
   UpperCAmelCase_   :   str     	=       0
   for i in range(1,						__lowerCamelCase    ):
      UpperCAmelCase_   :   Optional[Any]     	=       min(table[i + 1],						table[i] + 1    )
      # check if out of bounds
      if i * 2 <= number:
         UpperCAmelCase_   :   Tuple     	=       min(table[i * 2],						table[i] + 1    )
      # check if out of bounds
      if i * 3 <= number:
         UpperCAmelCase_   :   Union[str, Any]     	=       min(table[i * 3],						table[i] + 1    )
   return table[number]


if __name__ == "__main__":
    import doctest

    doctest.testmod()







import math





def 				A      (	_UpperCAmelCase							:  int       )							->					int:







			'''simple docstring'''
			return sum(int(_UpperCAmelCase       ) for digit in str(_UpperCAmelCase       )       )





def 				A      (	_UpperCAmelCase							:  int = 30       )							->					int:







			'''simple docstring'''
			_UpperCAmelCase									=  []
			for digit in range(2				,  100       ):
						for power in range(2				,  100       ):
									_UpperCAmelCase									=  int(math.pow(_UpperCAmelCase				,  _UpperCAmelCase       )       )
									if digit == digit_sum(_UpperCAmelCase       ):
												digit_to_powers.append(_UpperCAmelCase       )

			digit_to_powers.sort()
			return digit_to_powers[n - 1]


if __name__ == "__main__":
							print(solution())
