divisibleBy2 :: Int -> Int
divisibleBy2 n
  | n == 0 || n `mod` 2 /= 0 = 0
  | otherwise = succ $ divisibleBy2 (n `div` 2)

func :: Int -> Int -> [Int] -> Int
func ans _ [] = ans
func m acc (x:xs)
  | acc < count = func x count xs
  | otherwise = func m acc xs
  where
    count = divisibleBy2 x

main = do
  line <- getLine
  let
    n = read line :: Int
    ans = func 0 0 [1..n]
  putStrLn $ show ans
