import Control.Applicative ((<$>))
import Data.List (unfoldr)

main :: IO ()
main = solve <$> readLn >>= print

solve :: Integer -> Integer
solve = foldr (\a b -> a + 10 * b) 0 . unfoldr f
  where f x | x == 0 = Nothing
            | even x = Just (0, x `div` (-2))
            | otherwise = Just (1, (x-1) `div` (-2))
