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

solve :: Int -> Int
solve x = maximum $ perfectPower x

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