defmodule Main do
  def main do
    IO.gets("")
    |> String.trim()
    |> String.split("", trim: true)
    |> process([])
    |> Enum.join()
    |> IO.puts()
  end
  
  def process([], acc), do: acc
  def process(["B"  | tail], acc), do: process(tail, Enum.slice(acc, 0..-2))
  def process([head | tail], acc), do: process(tail, acc ++ [head])
end