f 0 s = s f x s = f (x `div` 2) (s+x) main = do t <- readLn :: IO Integer print $ t*2 - f t 0