import java.util.ArrayDeque;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;



public class Main {


	static List<Integer> ansset;

    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

    void run() {
    	Scanner sc=new Scanner(System.in);

    	String S=sc.next();

    	String[] input=S.split("");

    	Deque<String> result=new ArrayDeque<String>();

    	for(int i=0;i<input.length;i++) {

    		if(!input[i].equals("B")) {
    			result.push(input[i]);
    		}else {

    			if(!result.isEmpty()) {
    				result.pop();
    			}
    		}
    	}

    	int Size=result.size();
    	String buf="";
    	for(int i=0;i<Size;i++) {

    		if(!result.isEmpty()) {
    			buf=result.pollLast();
    		}

    		System.out.print(buf);
    	}

    	System.out.println();
    }
}
 import java.util.ArrayDeque; ArrayDeque java.util import java.util.Deque; Deque java.util import java.util.List; List java.util import java.util.Scanner; Scanner java.util public class Main {


	static List<Integer> ansset;

    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

    void run() {
    	Scanner sc=new Scanner(System.in);

    	String S=sc.next();

    	String[] input=S.split("");

    	Deque<String> result=new ArrayDeque<String>();

    	for(int i=0;i<input.length;i++) {

    		if(!input[i].equals("B")) {
    			result.push(input[i]);
    		}else {

    			if(!result.isEmpty()) {
    				result.pop();
    			}
    		}
    	}

    	int Size=result.size();
    	String buf="";
    	for(int i=0;i<Size;i++) {

    		if(!result.isEmpty()) {
    			buf=result.pollLast();
    		}

    		System.out.print(buf);
    	}

    	System.out.println();
    }
} Main static List<Integer> ansset; ansset public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    } main {

    	Main main=new Main();

    	main.run();

    } Main main=new Main(); main new Main() main.run() main.run main String[] args args void run() {
    	Scanner sc=new Scanner(System.in);

    	String S=sc.next();

    	String[] input=S.split("");

    	Deque<String> result=new ArrayDeque<String>();

    	for(int i=0;i<input.length;i++) {

    		if(!input[i].equals("B")) {
    			result.push(input[i]);
    		}else {

    			if(!result.isEmpty()) {
    				result.pop();
    			}
    		}
    	}

    	int Size=result.size();
    	String buf="";
    	for(int i=0;i<Size;i++) {

    		if(!result.isEmpty()) {
    			buf=result.pollLast();
    		}

    		System.out.print(buf);
    	}

    	System.out.println();
    } run {
    	Scanner sc=new Scanner(System.in);

    	String S=sc.next();

    	String[] input=S.split("");

    	Deque<String> result=new ArrayDeque<String>();

    	for(int i=0;i<input.length;i++) {

    		if(!input[i].equals("B")) {
    			result.push(input[i]);
    		}else {

    			if(!result.isEmpty()) {
    				result.pop();
    			}
    		}
    	}

    	int Size=result.size();
    	String buf="";
    	for(int i=0;i<Size;i++) {

    		if(!result.isEmpty()) {
    			buf=result.pollLast();
    		}

    		System.out.print(buf);
    	}

    	System.out.println();
    } Scanner sc=new Scanner(System.in); sc new Scanner(System.in) String S=sc.next(); S sc.next() sc.next sc String[] input=S.split(""); input S.split("") S.split S "" Deque<String> result=new ArrayDeque<String>(); result new ArrayDeque<String>() for(int i=0;i<input.length;i++) {

    		if(!input[i].equals("B")) {
    			result.push(input[i]);
    		}else {

    			if(!result.isEmpty()) {
    				result.pop();
    			}
    		}
    	} int i=0; int i=0; i 0 i<input.length i input.length input input.length i++ i++ i {

    		if(!input[i].equals("B")) {
    			result.push(input[i]);
    		}else {

    			if(!result.isEmpty()) {
    				result.pop();
    			}
    		}
    	} {

    		if(!input[i].equals("B")) {
    			result.push(input[i]);
    		}else {

    			if(!result.isEmpty()) {
    				result.pop();
    			}
    		}
    	} if(!input[i].equals("B")) {
    			result.push(input[i]);
    		}else {

    			if(!result.isEmpty()) {
    				result.pop();
    			}
    		} !input[i].equals("B") input[i].equals("B") input[i].equals input[i] input i "B" {
    			result.push(input[i]);
    		} result.push(input[i]) result.push result input[i] input i {

    			if(!result.isEmpty()) {
    				result.pop();
    			}
    		} if(!result.isEmpty()) {
    				result.pop();
    			} !result.isEmpty() result.isEmpty() result.isEmpty result {
    				result.pop();
    			} result.pop() result.pop result int Size=result.size(); Size result.size() result.size result String buf=""; buf "" for(int i=0;i<Size;i++) {

    		if(!result.isEmpty()) {
    			buf=result.pollLast();
    		}

    		System.out.print(buf);
    	} int i=0; int i=0; i 0 i<Size i Size i++ i++ i {

    		if(!result.isEmpty()) {
    			buf=result.pollLast();
    		}

    		System.out.print(buf);
    	} {

    		if(!result.isEmpty()) {
    			buf=result.pollLast();
    		}

    		System.out.print(buf);
    	} if(!result.isEmpty()) {
    			buf=result.pollLast();
    		} !result.isEmpty() result.isEmpty() result.isEmpty result {
    			buf=result.pollLast();
    		} buf=result.pollLast() buf result.pollLast() result.pollLast result System.out.print(buf) System.out.print System.out System System.out buf System.out.println() System.out.println System.out System System.out public class Main {


	static List<Integer> ansset;

    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

    void run() {
    	Scanner sc=new Scanner(System.in);

    	String S=sc.next();

    	String[] input=S.split("");

    	Deque<String> result=new ArrayDeque<String>();

    	for(int i=0;i<input.length;i++) {

    		if(!input[i].equals("B")) {
    			result.push(input[i]);
    		}else {

    			if(!result.isEmpty()) {
    				result.pop();
    			}
    		}
    	}

    	int Size=result.size();
    	String buf="";
    	for(int i=0;i<Size;i++) {

    		if(!result.isEmpty()) {
    			buf=result.pollLast();
    		}

    		System.out.print(buf);
    	}

    	System.out.println();
    }
} public class Main {


	static List<Integer> ansset;

    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

    void run() {
    	Scanner sc=new Scanner(System.in);

    	String S=sc.next();

    	String[] input=S.split("");

    	Deque<String> result=new ArrayDeque<String>();

    	for(int i=0;i<input.length;i++) {

    		if(!input[i].equals("B")) {
    			result.push(input[i]);
    		}else {

    			if(!result.isEmpty()) {
    				result.pop();
    			}
    		}
    	}

    	int Size=result.size();
    	String buf="";
    	for(int i=0;i<Size;i++) {

    		if(!result.isEmpty()) {
    			buf=result.pollLast();
    		}

    		System.out.print(buf);
    	}

    	System.out.println();
    }
} Main
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;



public class Main {


	static List<Integer> ansset;

    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

    void run() {
    	Scanner sc=new Scanner(System.in);

    	String S=sc.next();

    	String[] input=S.split("");

    	Deque<String> result=new ArrayDeque<String>();

    	for(int i=0;i<input.length;i++) {

    		if(!input[i].equals("B")) {
    			result.push(input[i]);
    		}else {

    			if(!result.isEmpty()) {
    				result.pop();
    			}
    		}
    	}

    	int Size=result.size();
    	String buf="";
    	for(int i=0;i<Size;i++) {

    		if(!result.isEmpty()) {
    			buf=result.pollLast();
    		}

    		System.out.print(buf);
    	}

    	System.out.println();
    }
}

