import           Control.Applicative
import           Control.Monad

import           Data.List             (sortBy)

-- 1024 = 2 ^ 10
-- 1024 = 32 ^ 2

f :: Int -> [Int]
f n = sortBy (flip compare)
      (1 : [b ^ p | b <- [2 .. 32], p <- [2 .. 10], b ^ p <= n])

main :: IO ()
main = do
    n <- readLn :: IO Int
    print $ head (f n)
