import qualified Data.ByteString.Char8 as B

main = B.getLine >>= B.putStrLn . solve

solve :: B.ByteString -> B.ByteString
solve = B.reverse . B.foldl ff B.empty
    where
        ff acc x
            | x == 'B' && not (B.null acc) = B.tail acc
            | x == 'B' = acc
            | otherwise = B.cons x acc
