import java.util.*;
public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
 
        String s = sc.next();
		String ans = "";
		for (int i = 0; i < s.length(); i++) {
			char key = s.charAt(i);
			if (key=='B') {
				int rightmost = ans.length() - 1;
				if (rightmost<=0) {
					ans = "";
				} else {
					ans = ans.substring(0, rightmost);
				}
			} else{
				ans += key;
			}
		}
		System.out.println(ans);
	}
} import java.util.*; util.* java public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
 
        String s = sc.next();
		String ans = "";
		for (int i = 0; i < s.length(); i++) {
			char key = s.charAt(i);
			if (key=='B') {
				int rightmost = ans.length() - 1;
				if (rightmost<=0) {
					ans = "";
				} else {
					ans = ans.substring(0, rightmost);
				}
			} else{
				ans += key;
			}
		}
		System.out.println(ans);
	}
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
 
        String s = sc.next();
		String ans = "";
		for (int i = 0; i < s.length(); i++) {
			char key = s.charAt(i);
			if (key=='B') {
				int rightmost = ans.length() - 1;
				if (rightmost<=0) {
					ans = "";
				} else {
					ans = ans.substring(0, rightmost);
				}
			} else{
				ans += key;
			}
		}
		System.out.println(ans);
	} main {
		Scanner sc = new Scanner(System.in);
 
        String s = sc.next();
		String ans = "";
		for (int i = 0; i < s.length(); i++) {
			char key = s.charAt(i);
			if (key=='B') {
				int rightmost = ans.length() - 1;
				if (rightmost<=0) {
					ans = "";
				} else {
					ans = ans.substring(0, rightmost);
				}
			} else{
				ans += key;
			}
		}
		System.out.println(ans);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc String ans = ""; ans "" for (int i = 0; i < s.length(); i++) {
			char key = s.charAt(i);
			if (key=='B') {
				int rightmost = ans.length() - 1;
				if (rightmost<=0) {
					ans = "";
				} else {
					ans = ans.substring(0, rightmost);
				}
			} else{
				ans += key;
			}
		} int i = 0; int i = 0; i 0 i < s.length() i s.length() s.length s i++ i++ i {
			char key = s.charAt(i);
			if (key=='B') {
				int rightmost = ans.length() - 1;
				if (rightmost<=0) {
					ans = "";
				} else {
					ans = ans.substring(0, rightmost);
				}
			} else{
				ans += key;
			}
		} {
			char key = s.charAt(i);
			if (key=='B') {
				int rightmost = ans.length() - 1;
				if (rightmost<=0) {
					ans = "";
				} else {
					ans = ans.substring(0, rightmost);
				}
			} else{
				ans += key;
			}
		} char key = s.charAt(i); key s.charAt(i) s.charAt s i if (key=='B') {
				int rightmost = ans.length() - 1;
				if (rightmost<=0) {
					ans = "";
				} else {
					ans = ans.substring(0, rightmost);
				}
			} else{
				ans += key;
			} key=='B' key 'B' {
				int rightmost = ans.length() - 1;
				if (rightmost<=0) {
					ans = "";
				} else {
					ans = ans.substring(0, rightmost);
				}
			} int rightmost = ans.length() - 1; rightmost ans.length() - 1 ans.length() ans.length ans 1 if (rightmost<=0) {
					ans = "";
				} else {
					ans = ans.substring(0, rightmost);
				} rightmost<=0 rightmost 0 {
					ans = "";
				} ans = "" ans "" {
					ans = ans.substring(0, rightmost);
				} ans = ans.substring(0, rightmost) ans ans.substring(0, rightmost) ans.substring ans 0 rightmost {
				ans += key;
			} ans += key ans key System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
 
        String s = sc.next();
		String ans = "";
		for (int i = 0; i < s.length(); i++) {
			char key = s.charAt(i);
			if (key=='B') {
				int rightmost = ans.length() - 1;
				if (rightmost<=0) {
					ans = "";
				} else {
					ans = ans.substring(0, rightmost);
				}
			} else{
				ans += key;
			}
		}
		System.out.println(ans);
	}
} public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
 
        String s = sc.next();
		String ans = "";
		for (int i = 0; i < s.length(); i++) {
			char key = s.charAt(i);
			if (key=='B') {
				int rightmost = ans.length() - 1;
				if (rightmost<=0) {
					ans = "";
				} else {
					ans = ans.substring(0, rightmost);
				}
			} else{
				ans += key;
			}
		}
		System.out.println(ans);
	}
} Main
import java.util.*;
public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
 
        String s = sc.next();
		String ans = "";
		for (int i = 0; i < s.length(); i++) {
			char key = s.charAt(i);
			if (key=='B') {
				int rightmost = ans.length() - 1;
				if (rightmost<=0) {
					ans = "";
				} else {
					ans = ans.substring(0, rightmost);
				}
			} else{
				ans += key;
			}
		}
		System.out.println(ans);
	}
}