local s = io.read()
local n = #s
local t = {}
for i = 1, n do
  local ss = s:sub(i, i)
  if ss == "B" then
    if 0 < #t then table.remove(t) end
  else
    table.insert(t, ss)
  end
end
print(table.concat(t))
