maxPowerLow :: Int -> Int -> Int
maxPowerLow x b
  | b == 1    = 1
  | otherwise = last $ takeWhile (<= x) $ map (\y -> b^y) [2..]

bs :: Int -> [Int]
bs x = takeWhile (\b -> b^2 <= x) [1..]

solve :: Int -> Int
solve x = maximum $ map (maxPowerLow x) $ bs x

main :: IO ()
main = do
  x <- readLn
  print $ solve x