main = do
  line <- getLine
  let 
    n = read line
    upmod n x
      | x < 0 = 
        let m = mod n x in 
          if m == 0 then 0
          else (-x)+m
      | otherwise = mod n x
    updiv n x
      | x < 0 =
        let u = upmod n x in
          if u == 0 then div n x
          else (div n x)+1
      | otherwise = div n x
    func n
      | n == 0 = [0]
      | n == 1 = [1]
      | otherwise = (upmod n (-2)) : (func $ updiv n (-2))
    output ls =
      putStrLn $ foldr (++) [] (map show $ reverse ls)
    in
      output $ func n
