import java.util.*;

@SuppressWarnings("unchecked")
public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String s = in.next();
		Stack<Character> stack = new Stack<>();
		for (int i = 0; i < s.length(); ++i) {
			char ch = s.charAt(i);
			if (ch == 'B') {
				if (!stack.isEmpty()) stack.pop();
			} else {
				stack.push(ch);
			}
		}
		String res = "";
		while (!stack.isEmpty()) {
			res += stack.pop();
		}
		for (int i = res.length() - 1; i >= 0; --i) {
			System.out.print(res.charAt(i));
		}
	}
} import java.util.*; util.* java public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String s = in.next();
		Stack<Character> stack = new Stack<>();
		for (int i = 0; i < s.length(); ++i) {
			char ch = s.charAt(i);
			if (ch == 'B') {
				if (!stack.isEmpty()) stack.pop();
			} else {
				stack.push(ch);
			}
		}
		String res = "";
		while (!stack.isEmpty()) {
			res += stack.pop();
		}
		for (int i = res.length() - 1; i >= 0; --i) {
			System.out.print(res.charAt(i));
		}
	}
} Main public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String s = in.next();
		Stack<Character> stack = new Stack<>();
		for (int i = 0; i < s.length(); ++i) {
			char ch = s.charAt(i);
			if (ch == 'B') {
				if (!stack.isEmpty()) stack.pop();
			} else {
				stack.push(ch);
			}
		}
		String res = "";
		while (!stack.isEmpty()) {
			res += stack.pop();
		}
		for (int i = res.length() - 1; i >= 0; --i) {
			System.out.print(res.charAt(i));
		}
	} main {
		Scanner in = new Scanner(System.in);
		String s = in.next();
		Stack<Character> stack = new Stack<>();
		for (int i = 0; i < s.length(); ++i) {
			char ch = s.charAt(i);
			if (ch == 'B') {
				if (!stack.isEmpty()) stack.pop();
			} else {
				stack.push(ch);
			}
		}
		String res = "";
		while (!stack.isEmpty()) {
			res += stack.pop();
		}
		for (int i = res.length() - 1; i >= 0; --i) {
			System.out.print(res.charAt(i));
		}
	} Scanner in = new Scanner(System.in); in new Scanner(System.in) String s = in.next(); s in.next() in.next in Stack<Character> stack = new Stack<>(); stack new Stack<>() for (int i = 0; i < s.length(); ++i) {
			char ch = s.charAt(i);
			if (ch == 'B') {
				if (!stack.isEmpty()) stack.pop();
			} else {
				stack.push(ch);
			}
		} int i = 0; int i = 0; i 0 i < s.length() i s.length() s.length s ++i ++i i {
			char ch = s.charAt(i);
			if (ch == 'B') {
				if (!stack.isEmpty()) stack.pop();
			} else {
				stack.push(ch);
			}
		} {
			char ch = s.charAt(i);
			if (ch == 'B') {
				if (!stack.isEmpty()) stack.pop();
			} else {
				stack.push(ch);
			}
		} char ch = s.charAt(i); ch s.charAt(i) s.charAt s i if (ch == 'B') {
				if (!stack.isEmpty()) stack.pop();
			} else {
				stack.push(ch);
			} ch == 'B' ch 'B' {
				if (!stack.isEmpty()) stack.pop();
			} if (!stack.isEmpty()) stack.pop(); !stack.isEmpty() stack.isEmpty() stack.isEmpty stack stack.pop() stack.pop stack {
				stack.push(ch);
			} stack.push(ch) stack.push stack ch String res = ""; res "" while (!stack.isEmpty()) {
			res += stack.pop();
		} !stack.isEmpty() stack.isEmpty() stack.isEmpty stack {
			res += stack.pop();
		} res += stack.pop() res stack.pop() stack.pop stack for (int i = res.length() - 1; i >= 0; --i) {
			System.out.print(res.charAt(i));
		} int i = res.length() - 1; int i = res.length() - 1; i res.length() - 1 res.length() res.length res 1 i >= 0 i 0 --i --i i {
			System.out.print(res.charAt(i));
		} {
			System.out.print(res.charAt(i));
		} System.out.print(res.charAt(i)) System.out.print System.out System System.out res.charAt(i) res.charAt res i String[] args args public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String s = in.next();
		Stack<Character> stack = new Stack<>();
		for (int i = 0; i < s.length(); ++i) {
			char ch = s.charAt(i);
			if (ch == 'B') {
				if (!stack.isEmpty()) stack.pop();
			} else {
				stack.push(ch);
			}
		}
		String res = "";
		while (!stack.isEmpty()) {
			res += stack.pop();
		}
		for (int i = res.length() - 1; i >= 0; --i) {
			System.out.print(res.charAt(i));
		}
	}
} public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String s = in.next();
		Stack<Character> stack = new Stack<>();
		for (int i = 0; i < s.length(); ++i) {
			char ch = s.charAt(i);
			if (ch == 'B') {
				if (!stack.isEmpty()) stack.pop();
			} else {
				stack.push(ch);
			}
		}
		String res = "";
		while (!stack.isEmpty()) {
			res += stack.pop();
		}
		for (int i = res.length() - 1; i >= 0; --i) {
			System.out.print(res.charAt(i));
		}
	}
} Main
import java.util.*;

@SuppressWarnings("unchecked")
public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String s = in.next();
		Stack<Character> stack = new Stack<>();
		for (int i = 0; i < s.length(); ++i) {
			char ch = s.charAt(i);
			if (ch == 'B') {
				if (!stack.isEmpty()) stack.pop();
			} else {
				stack.push(ch);
			}
		}
		String res = "";
		while (!stack.isEmpty()) {
			res += stack.pop();
		}
		for (int i = res.length() - 1; i >= 0; --i) {
			System.out.print(res.charAt(i));
		}
	}
}