solve :: Int -> Int -> Int -> Int
solve current x n
  | n == 1 = 1
  | current == 1 = solve (n * n) x n
  | x < (current * n) = current
  | otherwise = solve (n * current) x n

main = do
  x <- readLn :: IO Int
  print $ maximum $ filter (\n -> n <= x) (map (solve 1 x) [1 .. 32])