module Main where

import Control.Applicative
import Control.Monad.State
import Data.List

work :: State (String, String) ()
work = do
    (s:sx, t) <- get
    case s of
        'B' -> if null t then put (sx, t) else put (sx, init t)
        _   -> put (sx, t ++ [s])
    unless (null sx) work

main :: IO ()
main = do
    line <- getLine
    putStrLn $ snd $ execState work (line, "")
