import Data.List
import Data.Ord
import Data.Char
import Data.Ratio
import Data.Maybe
import Control.Monad

main = do
  x <- readLn :: IO Int
  print $ maximum [n|b<-[1..32], p<-[2..10], let n=b^p, n<=x]