import Data.List (foldl')

pressKey :: String -> Char -> String
pressKey s '0' = s ++ "0"
pressKey s '1' = s ++ "1"
pressKey [] 'B' = []
pressKey s 'B' = init s
pressKey s _ = s

pressKeys :: String -> String -> String
pressKeys = foldl' pressKey

main :: IO ()
main = putStrLn . pressKeys [] =<< getLine
