import Control.Arrow
import Data.Char
import Data.List

main :: IO ()
main = do
  x <- getInt
  print . maximum $ 1 : [b ^ p | b <- [1..x], p <- [2..lim x], b ^ p <= x]

getInt :: IO Int
getInt = readLn
