main = putStrLn =<< solve <$> getLine

solve :: String -> String
solve s = solve' s ""

solve' :: String -> String -> String
solve' [] s = s
solve' (x:xs) s
    | x == '0' = solve' xs $ s ++ "0"
    | x == '1' = solve' xs $ s ++ "1"
    | x == 'B' = if s == [] then solve' xs s else solve' xs $ init s
    | otherwise = error "unexpected char"
