import Data.List
import Data.Maybe

solve :: Int -> Int
solve n
  | n `mod` 2 /= 0 = 0
  | otherwise = 1 + solve (n `div` 2)

main :: IO ()
main = do
  n <- readLn
  let res = solve <$> [2..n]
  print . (+2) . fromJust $ maximum res `elemIndex` res