open Batteries
open Printf
let () =
  let s = Scanf.scanf "%s " (fun a -> a) in
  let c_l = String.to_list s in

  let rec aux res = function
    | [] -> res
    | hd :: tl -> if hd = 'B' then
        let res = String.slice ~last:(String.length res - 1) res in
        aux res tl
      else 
        let res = res ^ (String.of_char hd) in
        aux res tl
  in

  Printf.printf "%s\n" @@
  aux "" c_l
