import Data.List

main = do
    n <- readLn :: IO Int
    let ns = [1 .. n]
    let maxPow = maximum $ filter (\x -> elem x ns) $ map (2 ^) [0 .. floor $ logBase 2.0 (fromIntegral n :: Float)]
    let (Just i) = elemIndex maxPow ns
    print $ ns !! i