fun main(args: Array<String>) {
    val s = readLine()!!
    val stack = mutableListOf<Char>()
    for (c in s) {
        if (c == 'B') {
            if (stack.isNotEmpty()) {
                stack.removeAt(stack.size - 1)
            }
        } else {
            stack.add(c)
        }
    }
    println(stack.joinToString(""))
}