
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val s = sc.next
  val cs: Seq[Char] = s.toCharArray.toList

  def solve(cs: Seq[Char], acc: String): String = cs match {
    case x +: xs =>
      x match {
        case 'B' => if (acc.isEmpty) solve(xs, "") else solve(xs, acc.substring(0, acc.length - 1))
        case z => solve(xs, acc + z)
      }
    case _ => acc
  }

  val ans = solve(cs, "")

  println(ans)
}
