import std.stdio;
import std.string, std.conv, std.array, std.algorithm;
import std.uni, std.math, std.container;
import core.bitop, std.datetime;

void main(){
    auto s = readln.chomp;
    auto stack = new Stack!(char)(s.length.to!int);

    foreach(c;s){
        if(c == 'B'){
            if(!stack.isEmpty) stack.pop();
        } else{
            stack.push(c);
        }
    }

    stack.print;
}

class Stack(T){
    private T[] stack;
    private int top, size;

    this(int N){
        stack = new T[](N + 1);
        size = N + 1;
    }

    bool isEmpty(){
        return top == 0;
    }

    bool isFull(){
        return top >= size;
    }

    void push(T stuff){
        ++top;
        if(isFull) throw new Exception("Stack is Full.");
        stack[top] = stuff;
    }

    auto pop(){
        if(isEmpty) throw new Exception("Stack is Empty.");
        auto ret = stack[top];
        --top;
        return ret;
    }

    auto print(){
        foreach(i ; 1 .. top + 1){
            write(stack[i]);
        }
        writeln;
    }
}