main :: IO ()
main = do
    x <- read <$> getLine
    putStrLn $ show $ solve x

solve :: Int -> Int
solve x = maximum $ filter isExp [1..x]


isExp :: Int -> Bool
-- xがべき乗数か判定

isExp 1 = True
isExp x =
    length (filter judge [a | a <- [2..x], x `mod` a == 0]) > 0
    where judge = \m -> case isExpOf x m of
            Nothing   -> False
            Just n    -> n > 1


isExpOf :: Int -> Int -> Maybe Int
-- aをbの累乗で表せるか判定
-- 表せなかったらNothing、表せたら指数を返す

isExpOf 1 _ = Just 0
isExpOf x m = 
    case (x `mod` m == 0) of
        False -> Nothing
        True  -> do
            n <- isExpOf (x `div` m) m
            return (n + 1)