{-# OPTIONS_GHC -O #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ViewPatterns #-}

import Control.Monad
import Data.List

pow b n = takeWhile (<=n) $ map (b^) [2..]

main = do
    x <- readLn
    if x <= 3
        then print x
        else do
            let x_2 = truncate $ sqrt $ fromIntegral x
            print $ maximum $ concat [ pow b x | b <- [2..x_2]]
