import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		char[] s = sc.next().toCharArray();
		sc.close();
		char[] a = new char[s.length+1];
		int p=0;
		for (i = 0; i < s.length; i++) {
			if(s[i]=='B') {
				if(p>0) {
					p--;
					a[p]='\u0000';
				}
			} else {
				a[p]=s[i];
				p++;
			}
		}
		for (i = 0; a[i] != '\u0000'; i++) {
			out.print(a[i]);
		}
		out.println();
	}
} import java.util.*; util.* java import java.io.PrintWriter; PrintWriter java.io import static java.lang.Integer.*; import static java.lang.Integer.*; import static java.lang.Integer.*; import static java.lang.Long.*; import static java.lang.Long.*; import static java.lang.Long.*; import static java.lang.Math.*; import static java.lang.Math.*; import static java.lang.Math.*; import static java.lang.System.*; import static java.lang.System.*; import static java.lang.System.*; public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		char[] s = sc.next().toCharArray();
		sc.close();
		char[] a = new char[s.length+1];
		int p=0;
		for (i = 0; i < s.length; i++) {
			if(s[i]=='B') {
				if(p>0) {
					p--;
					a[p]='\u0000';
				}
			} else {
				a[p]=s[i];
				p++;
			}
		}
		for (i = 0; a[i] != '\u0000'; i++) {
			out.print(a[i]);
		}
		out.println();
	}
} Main public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		char[] s = sc.next().toCharArray();
		sc.close();
		char[] a = new char[s.length+1];
		int p=0;
		for (i = 0; i < s.length; i++) {
			if(s[i]=='B') {
				if(p>0) {
					p--;
					a[p]='\u0000';
				}
			} else {
				a[p]=s[i];
				p++;
			}
		}
		for (i = 0; a[i] != '\u0000'; i++) {
			out.print(a[i]);
		}
		out.println();
	} main {
		int i,j;
		Scanner sc = new Scanner(in);
		char[] s = sc.next().toCharArray();
		sc.close();
		char[] a = new char[s.length+1];
		int p=0;
		for (i = 0; i < s.length; i++) {
			if(s[i]=='B') {
				if(p>0) {
					p--;
					a[p]='\u0000';
				}
			} else {
				a[p]=s[i];
				p++;
			}
		}
		for (i = 0; a[i] != '\u0000'; i++) {
			out.print(a[i]);
		}
		out.println();
	} int i i j; j Scanner sc = new Scanner(in); sc new Scanner(in) char[] s = sc.next().toCharArray(); s sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc sc.close() sc.close sc char[] a = new char[s.length+1]; a new char[s.length+1] s.length+1 s.length s s.length 1 int p=0; p 0 for (i = 0; i < s.length; i++) {
			if(s[i]=='B') {
				if(p>0) {
					p--;
					a[p]='\u0000';
				}
			} else {
				a[p]=s[i];
				p++;
			}
		} i = 0; i = 0 i 0 i < s.length i s.length s s.length i++ i++ i {
			if(s[i]=='B') {
				if(p>0) {
					p--;
					a[p]='\u0000';
				}
			} else {
				a[p]=s[i];
				p++;
			}
		} {
			if(s[i]=='B') {
				if(p>0) {
					p--;
					a[p]='\u0000';
				}
			} else {
				a[p]=s[i];
				p++;
			}
		} if(s[i]=='B') {
				if(p>0) {
					p--;
					a[p]='\u0000';
				}
			} else {
				a[p]=s[i];
				p++;
			} s[i]=='B' s[i] s i 'B' {
				if(p>0) {
					p--;
					a[p]='\u0000';
				}
			} if(p>0) {
					p--;
					a[p]='\u0000';
				} p>0 p 0 {
					p--;
					a[p]='\u0000';
				} p-- p a[p]='\u0000' a[p] a p '\u0000' {
				a[p]=s[i];
				p++;
			} a[p]=s[i] a[p] a p s[i] s i p++ p for (i = 0; a[i] != '\u0000'; i++) {
			out.print(a[i]);
		} i = 0; i = 0 i 0 a[i] != '\u0000' a[i] a i '\u0000' i++ i++ i {
			out.print(a[i]);
		} {
			out.print(a[i]);
		} out.print(a[i]) out.print out a[i] a i out.println() out.println out String[] args args public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		char[] s = sc.next().toCharArray();
		sc.close();
		char[] a = new char[s.length+1];
		int p=0;
		for (i = 0; i < s.length; i++) {
			if(s[i]=='B') {
				if(p>0) {
					p--;
					a[p]='\u0000';
				}
			} else {
				a[p]=s[i];
				p++;
			}
		}
		for (i = 0; a[i] != '\u0000'; i++) {
			out.print(a[i]);
		}
		out.println();
	}
} public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		char[] s = sc.next().toCharArray();
		sc.close();
		char[] a = new char[s.length+1];
		int p=0;
		for (i = 0; i < s.length; i++) {
			if(s[i]=='B') {
				if(p>0) {
					p--;
					a[p]='\u0000';
				}
			} else {
				a[p]=s[i];
				p++;
			}
		}
		for (i = 0; a[i] != '\u0000'; i++) {
			out.print(a[i]);
		}
		out.println();
	}
} Main
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		char[] s = sc.next().toCharArray();
		sc.close();
		char[] a = new char[s.length+1];
		int p=0;
		for (i = 0; i < s.length; i++) {
			if(s[i]=='B') {
				if(p>0) {
					p--;
					a[p]='\u0000';
				}
			} else {
				a[p]=s[i];
				p++;
			}
		}
		for (i = 0; a[i] != '\u0000'; i++) {
			out.print(a[i]);
		}
		out.println();
	}
}
