perfectPower :: Integer -> [Integer]
perfectPower x = 1 : do
  p <- [2 .. floor (0.001 + sqrt (fromIntegral x))]
  return $ floor (0.001 + fromIntegral x ** (1 / fromIntegral p)) ^ p

solve :: Integer -> Integer
solve x = maximum $ filter (<= x) $ perfectPower x

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