solve :: Int -> Int
solve x = maximum $ 1 : [ b ^ floor (logBase (fromIntegral b) (fromIntegral x)) | b <- bs ]
  where
    bs = [2 .. floor (sqrt (fromIntegral x))]

main :: IO ()
main = do
  x <- read <$> getLine
  print . solve $ x
