You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.
x = int(input())
i = 1
while i ** i <= x:
  i += 1
i -= 1
print(i ** i)

x = int(input())
if x < 4:
  print(1)
else:
  ans = 2
  for i in range(2, x):
    for j in range(2, x):
      if i ** j <= x:
        ans = max(ans, i ** j)
      else:
        break
  print(ans)