solve :: String -> String -> String
solve [] txt = txt
solve (o:os) txt
  | o == 'B' = solve os $ if null txt then "" else init txt
  | otherwise = solve os $ txt ++ [o]

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