import java.util.Scanner;
import java.util.Stack;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		
		String s [] = S.split("");
		Stack <String> stack = new Stack <>();
		
		for (int i=0; i<S.length(); i++){
			if (s[i].equals("B")){
				if (stack.isEmpty()!=true)
					stack.pop();
			}
			
			else
				stack.push(s[i]);
				
		}
		String ans = "";
		for (int i=0; i<stack.size(); i++){
			ans+=stack.get(i);
		}
		System.out.println(ans);
		sc.close();
	}

} import java.util.Scanner; Scanner java.util import java.util.Stack; Stack java.util public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		
		String s [] = S.split("");
		Stack <String> stack = new Stack <>();
		
		for (int i=0; i<S.length(); i++){
			if (s[i].equals("B")){
				if (stack.isEmpty()!=true)
					stack.pop();
			}
			
			else
				stack.push(s[i]);
				
		}
		String ans = "";
		for (int i=0; i<stack.size(); i++){
			ans+=stack.get(i);
		}
		System.out.println(ans);
		sc.close();
	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		
		String s [] = S.split("");
		Stack <String> stack = new Stack <>();
		
		for (int i=0; i<S.length(); i++){
			if (s[i].equals("B")){
				if (stack.isEmpty()!=true)
					stack.pop();
			}
			
			else
				stack.push(s[i]);
				
		}
		String ans = "";
		for (int i=0; i<stack.size(); i++){
			ans+=stack.get(i);
		}
		System.out.println(ans);
		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		
		String s [] = S.split("");
		Stack <String> stack = new Stack <>();
		
		for (int i=0; i<S.length(); i++){
			if (s[i].equals("B")){
				if (stack.isEmpty()!=true)
					stack.pop();
			}
			
			else
				stack.push(s[i]);
				
		}
		String ans = "";
		for (int i=0; i<stack.size(); i++){
			ans+=stack.get(i);
		}
		System.out.println(ans);
		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String S = sc.next(); S sc.next() sc.next sc String s [] = S.split(""); s S.split("") S.split S "" Stack <String> stack = new Stack <>(); stack new Stack <>() for (int i=0; i<S.length(); i++){
			if (s[i].equals("B")){
				if (stack.isEmpty()!=true)
					stack.pop();
			}
			
			else
				stack.push(s[i]);
				
		} int i=0; int i=0; i 0 i<S.length() i S.length() S.length S i++ i++ i {
			if (s[i].equals("B")){
				if (stack.isEmpty()!=true)
					stack.pop();
			}
			
			else
				stack.push(s[i]);
				
		} {
			if (s[i].equals("B")){
				if (stack.isEmpty()!=true)
					stack.pop();
			}
			
			else
				stack.push(s[i]);
				
		} if (s[i].equals("B")){
				if (stack.isEmpty()!=true)
					stack.pop();
			}
			
			else
				stack.push(s[i]); s[i].equals("B") s[i].equals s[i] s i "B" {
				if (stack.isEmpty()!=true)
					stack.pop();
			} if (stack.isEmpty()!=true)
					stack.pop(); stack.isEmpty()!=true stack.isEmpty() stack.isEmpty stack true stack.pop() stack.pop stack stack.push(s[i]) stack.push stack s[i] s i String ans = ""; ans "" for (int i=0; i<stack.size(); i++){
			ans+=stack.get(i);
		} int i=0; int i=0; i 0 i<stack.size() i stack.size() stack.size stack i++ i++ i {
			ans+=stack.get(i);
		} {
			ans+=stack.get(i);
		} ans+=stack.get(i) ans stack.get(i) stack.get stack i System.out.println(ans) System.out.println System.out System System.out ans sc.close() sc.close sc String[] args args public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		
		String s [] = S.split("");
		Stack <String> stack = new Stack <>();
		
		for (int i=0; i<S.length(); i++){
			if (s[i].equals("B")){
				if (stack.isEmpty()!=true)
					stack.pop();
			}
			
			else
				stack.push(s[i]);
				
		}
		String ans = "";
		for (int i=0; i<stack.size(); i++){
			ans+=stack.get(i);
		}
		System.out.println(ans);
		sc.close();
	}

} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		
		String s [] = S.split("");
		Stack <String> stack = new Stack <>();
		
		for (int i=0; i<S.length(); i++){
			if (s[i].equals("B")){
				if (stack.isEmpty()!=true)
					stack.pop();
			}
			
			else
				stack.push(s[i]);
				
		}
		String ans = "";
		for (int i=0; i<stack.size(); i++){
			ans+=stack.get(i);
		}
		System.out.println(ans);
		sc.close();
	}

} Main
import java.util.Scanner;
import java.util.Stack;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		
		String s [] = S.split("");
		Stack <String> stack = new Stack <>();
		
		for (int i=0; i<S.length(); i++){
			if (s[i].equals("B")){
				if (stack.isEmpty()!=true)
					stack.pop();
			}
			
			else
				stack.push(s[i]);
				
		}
		String ans = "";
		for (int i=0; i<stack.size(); i++){
			ans+=stack.get(i);
		}
		System.out.println(ans);
		sc.close();
	}

}
