import java.util.ArrayDeque

fun main(args: Array<String>) {
    val result = ArrayDeque<Char>()
    readLine()!!.forEach {
        when (it) {
            'B' -> if (result.isNotEmpty()) { result.pop() }
            else -> result.push(it)
        }
    }
    println(result.reversed().joinToString(""))
}
