main :: IO ()
main = do
  input <- getLine
  putStrLn $ solve (reverse input) []

solve :: String -> String -> String
solve [] res = res
solve str@(s:ss) res
  | s == 'B' = solve (delete str) res
  | otherwise = solve ss $s:res

delete :: String -> String
delete str = drop n str
  where
    n = 2 * (length . takeWhile (== 'B')) str
