import Data.List

main = do
    x <- read <$> getLine
    print $ exponential x

exponential x = maximum [pow | b <- [1..x], let pow = maxPower b 2, pow <= x]
    where
        maxPower 1 p = 1
        maxPower b p =
            if (b^(p+1) <= x)
                then maxPower b (p + 1)
                else b^p