main :: IO ()
main = do
  n <- read <$> getLine :: IO Int
  print $ solve n

solve :: Int -> Int
solve n = let m = ceiling $ sqrt $ fromIntegral n
          in maximum . filter (<= n) $ 1:[i ^j | i <- [1..m], j <- [2..m]]
