import Data.List
main = getContents >>= putStr . fout . switching_cars . fin . lines
fin = id
fout = unlines . map head
  
switching_cars cs = filter (not . null) $ zipWith (\\) keeplog (tail keeplog)
 where keeplog = scanl (\acc c -> if c=="0" then tail acc else c:acc) [] cs