{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

import Debug.Trace

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = readLn >>= putStrLn . reverse . concatMap show . solve 2 1

solve 2 _ 0 = [ 0 ]
solve _ _ 0 = []
solve m sgn n
	| n `mod` m /= 0 = 1 : solve' ( n - sgn * m `div` 2 )
	| otherwise = 0 : solve' n
	where
		solve' = solve ( m * 2 ) ( -sgn )