import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val s = in.readLine()

    out.println(
      s.foldLeft[List[Char]](Nil) {
        case (acc, c) => c match {
          case 'B' if acc != Nil =>
            acc.tail
          case 'B' =>
            acc
          case c => c :: acc
        }
      }.reverse.mkString("")
    )

    out.flush()
  }
}
