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