module Main where

main = do
  s <- getLine
  putStrLn $ reverse $ foldl op [] s
  return ()

op str c
  | c == 'B' = if null str
               then str
               else tail str
  | otherwise = c:str
