{-# LANGUAGE FlexibleContexts, OverloadedStrings #-}
import Control.Applicative
import Control.Monad
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)
import Text.Printf
import Debug.Trace
import Data.List (sort)

f n = length $ takeWhile (\x -> x `mod` 2 == 0) $ iterate (`div`2) n

main = do
  [n] <- getInts
  let xs = sort $ take (n+1) $ iterate (\(x,y)->(f (y+1),y+1)) (0,0)
  print $ snd $ last xs
  
-- util
getInts :: IO [Int]
getInts = map (fst . fromJust . B.readInt) . B.words <$> B.getLine
