import Control.Monad

perfectPower :: Integer -> [Integer]
perfectPower x = 1 : do
  b <- [2 .. floor $ sqrt $ fromIntegral x]
  p <- [2 .. floor $ sqrt $ fromIntegral x]
  guard (b^p <= x)
  return $ b^p

solve :: Integer -> Integer
solve x = maximum $ filter (<= x) $ perfectPower x

main :: IO ()
main = do
  x <- read <$> getLine
  print . solve $ x
