main = do n <- readLn :: IO Integer let l = takeWhile (>0) [ n `div` 2^x | x <- [0,1..] ] putStrLn . show $ n * 2 - sum l