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

solve :: Int -> Int
solve x = maximum [ solve' x p | p <- ps ]
  where ps = takeWhile (\p -> 2 ^ p <= x) [2 .. ]

solve' x p = last $ takeWhile (\b -> b ^ p <= x) [1 .. ]

