  // B - バイナリハックイージー / Unhappy Hacking (ABC Edit) https://atcoder.jp/contests/abc043/tasks/abc043_b

  import io.Source

  object Main extends App {
    Source.stdin.getLines().foreach(l => println(solve(l)))

    def solve(s: String): String = {
      var a = ""
      s.foreach { c =>
        c match {
          case 'B' => a = if (a.length > 0) a.substring(0, a.length - 1) else a
          case ch => a += ch
        }
      }
      a
    }
  }
