import           Data.List
import           Control.Applicative
import           Control.Monad

bekis :: Int -> [Int]
bekis n = sort
  [ b ^ p
  | b <- [1 .. (ceiling . sqrt . fromIntegral) n]
  , p <- [2 .. (ceiling . logBase 2) (fromIntegral n)]
  , b ^ p <= n
  ]

main = do
  n <- readLn
  print $ last $ bekis n
