(* O(|s|) *)
let s = read_line ()
let b = Bytes.make 10 ' '
let i = ref 0
let f c =
  match c with
  | 'B' -> if !i > 0 then decr i
  | _ -> Bytes.set b !i c; incr i
let _ =
  String.iter f s;
  Bytes.sub_string b 0 !i |> print_endline