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

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

getInt :: IO Int
getInt = readLn
