import Control.Applicative

main :: IO ()
main = do
    n <- readLn
    putStrLn $ show (solve n)
   
solve :: Int -> Int
solve n = (1 - 2 ^ (1 + divid n 0)) `div` (1 - 2)

divid :: Int -> Int -> Int 
divid n z = if n `div` 2 > 0 
            then  divid (n `div` 2) (z + 1)
            else  z