main :: IO ()
main = do
  s <- getLine
  putStrLn $ solve s ""

solve :: String -> String -> String
solve "" s = s
solve (o : os) s | s == "" && o == 'B' = solve os s
                 | o == 'B'            = solve os $ init s
                 | otherwise           = solve os $ s ++ [o]
