import math as m







def 						UpperCAmelCase							(		lowerCAmelCase_    ,   lowerCAmelCase_    ,   lowerCAmelCase_=0.0_01							)						->						int:
     return (f(a + h							) - f(a - h							)) / (2 * h)







def 						UpperCAmelCase							(		lowerCAmelCase_    ,   lowerCAmelCase_=0    ,   lowerCAmelCase_=1_0_0    ,   lowerCAmelCase_=0.00_01    ,   lowerCAmelCase_=1e-6    ,   lowerCAmelCase_=False							)						->						int:
     a	:     int						      =    xa  # set the initial guess
     a	:     Optional[Any]						      =    [a]
     a	:     List[str]						      =    abs(f(lowerCAmelCase_							)							)
     a	:     List[str]						      =    lambda lowerCAmelCase_							: calc_derivative(lowerCAmelCase_    ,   lowerCAmelCase_    ,   h=lowerCAmelCase_							)  # noqa: E731  Derivative of f(x)
     for _ in range(lowerCAmelCase_							):
          if fa(lowerCAmelCase_							) == 0:
               raise ValueError('''No converging solution found'''							)
          a	:     str						      =    a - f(lowerCAmelCase_							) / fa(lowerCAmelCase_							)  # Calculate the next estimate
          if logsteps:
               steps.append(lowerCAmelCase_							)
          if error < maxerror:
               break
     else:
          raise ValueError('''Iteration limit reached, no converging solution found'''							)
     if logsteps:
          # If logstep is true, then log intermediate steps
          return a, error, steps
     return a, error


if __name__ == "__main__":
  from matplotlib import pyplot as plt

  UpperCAmelCase				 =   lambda x: m.tanh(x) ** 2 - m.exp(3 * x)  # noqa: E731
  UpperCAmelCase ,	UpperCAmelCase ,	UpperCAmelCase				 =   newton_raphson(
      f, xa=10, maxiter=1000, step=1E-6, logsteps=True
  )
  plt.plot([abs(f(x)) for x in steps])
  plt.xlabel("""step""")
  plt.ylabel("""error""")
  plt.show()
  print(F'''solution = {{{solution:f}}}, error = {{{error:f}}}''')
import math







def 						UpperCAmelCase							(		lowerCAmelCase_							)						->						int:
     return sum(int(lowerCAmelCase_							) for digit in str(lowerCAmelCase_							)							)







def 						UpperCAmelCase							(		lowerCAmelCase_ = 3_0							)						->						int:
     a	:     Optional[int]						      =    []
     for digit in range(2    ,   1_0_0							):
          for power in range(2    ,   1_0_0							):
               a	:     List[str]						      =    int(math.pow(lowerCAmelCase_    ,   lowerCAmelCase_							)							)
               if digit == digit_sum(lowerCAmelCase_							):
                    digit_to_powers.append(lowerCAmelCase_							)

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


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