object Main extends App {

  import scala.io.StdIn.readLine
  val arr = readLine().trim.split("")
  val stack = new scala.collection.mutable.Stack[String]
  arr.foreach { e =>
    if (e == "B") {
      if (stack.isEmpty) {
        ()
      } else {
        stack.pop
      }
    } else {
      stack.push(e)
    }
  }
  println(stack.toList.reverse.mkString)

}
