let string_to_list str =
  let rec loop i limit =
    if i = limit then []
    else (String.get str i) :: (loop (i + 1) limit)
  in
  loop 0 (String.length str)

let solve list =
  let rec aux list ans =
    begin match list with
    | [] -> ans
    | '0'::rest -> aux rest ('0'::ans)
    | '1'::rest -> aux rest ('1'::ans)
    | 'B'::rest -> begin match ans with
                  | [] -> aux rest ans
                  | x::ansrest -> aux rest ansrest
                  end
    | _ -> ans
    end
  in
  aux list []

let () =
  let rec read () =
    try let ans = (Scanf.scanf "%s\n" (fun x -> solve (string_to_list x)) ) in
        Printf.printf "%s\n" (List.fold_left (fun x y -> x ^ (String.make 1 y)) "" ans)
    with End_of_file -> ()
  in
  read ()
;;
