{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE InstanceSigs #-}

import Control.Monad
import Data.List

inputChar :: String -> Char -> String
inputChar [] 'B' = []
inputChar s 'B' = init s
inputChar s c = s ++ [c]

main :: IO ()
main = do
    s <- getLine
    putStrLn $ foldl inputChar [] s