import java.util.ArrayDeque

fun main(args: Array<String>) {
    val s = readString()

    var q = ArrayDeque<Char>()
    s.forEach {
        when (it) {
            'B' -> q.pollLast()
            else -> q.addLast(it)
        }
    }
    println(q.joinToString(separator = ""))
}

// Tools
fun readString() = readLine()!!