import java.io.*;
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
		InputReader in = new InputReader();
		String str = in.next();
		
		String res = "";
		for (int i=0; i<str.length(); i++) {
			if (str.charAt(i) == 'B') {
				if (res.length() != 0)
					res = res.substring(0, res.length()-1);
			}
			else
				res += str.charAt(i);
		}
		System.out.println(res);
	}

	static class InputReader {
		public BufferedReader br;
		public StringTokenizer st;
		
		public InputReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
			st = null;
		}
		
		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}
	}
} import java.io.*; io.* java import java.util.*; util.* java public class Main {
	
	public static void main(String[] args) {
		InputReader in = new InputReader();
		String str = in.next();
		
		String res = "";
		for (int i=0; i<str.length(); i++) {
			if (str.charAt(i) == 'B') {
				if (res.length() != 0)
					res = res.substring(0, res.length()-1);
			}
			else
				res += str.charAt(i);
		}
		System.out.println(res);
	}

	static class InputReader {
		public BufferedReader br;
		public StringTokenizer st;
		
		public InputReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
			st = null;
		}
		
		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}
	}
} Main public static void main(String[] args) {
		InputReader in = new InputReader();
		String str = in.next();
		
		String res = "";
		for (int i=0; i<str.length(); i++) {
			if (str.charAt(i) == 'B') {
				if (res.length() != 0)
					res = res.substring(0, res.length()-1);
			}
			else
				res += str.charAt(i);
		}
		System.out.println(res);
	} main {
		InputReader in = new InputReader();
		String str = in.next();
		
		String res = "";
		for (int i=0; i<str.length(); i++) {
			if (str.charAt(i) == 'B') {
				if (res.length() != 0)
					res = res.substring(0, res.length()-1);
			}
			else
				res += str.charAt(i);
		}
		System.out.println(res);
	} InputReader in = new InputReader(); in new InputReader() String str = in.next(); str in.next() in.next in String res = ""; res "" for (int i=0; i<str.length(); i++) {
			if (str.charAt(i) == 'B') {
				if (res.length() != 0)
					res = res.substring(0, res.length()-1);
			}
			else
				res += str.charAt(i);
		} int i=0; int i=0; i 0 i<str.length() i str.length() str.length str i++ i++ i {
			if (str.charAt(i) == 'B') {
				if (res.length() != 0)
					res = res.substring(0, res.length()-1);
			}
			else
				res += str.charAt(i);
		} {
			if (str.charAt(i) == 'B') {
				if (res.length() != 0)
					res = res.substring(0, res.length()-1);
			}
			else
				res += str.charAt(i);
		} if (str.charAt(i) == 'B') {
				if (res.length() != 0)
					res = res.substring(0, res.length()-1);
			}
			else
				res += str.charAt(i); str.charAt(i) == 'B' str.charAt(i) str.charAt str i 'B' {
				if (res.length() != 0)
					res = res.substring(0, res.length()-1);
			} if (res.length() != 0)
					res = res.substring(0, res.length()-1); res.length() != 0 res.length() res.length res 0 res = res.substring(0, res.length()-1) res res.substring(0, res.length()-1) res.substring res 0 res.length()-1 res.length() res.length res 1 res += str.charAt(i) res str.charAt(i) str.charAt str i System.out.println(res) System.out.println System.out System System.out res String[] args args static class InputReader {
		public BufferedReader br;
		public StringTokenizer st;
		
		public InputReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
			st = null;
		}
		
		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}
	} InputReader public BufferedReader br; br public StringTokenizer st; st public InputReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
			st = null;
		} InputReader {
			br = new BufferedReader(new InputStreamReader(System.in));
			st = null;
		} br = new BufferedReader(new InputStreamReader(System.in)) br new BufferedReader(new InputStreamReader(System.in)) st = null st null public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		} next {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		} while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e) {
					throw new RuntimeException(e);
				}
			} st == null || !st.hasMoreTokens() st == null st null !st.hasMoreTokens() st.hasMoreTokens() st.hasMoreTokens st {
				try {
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e) {
					throw new RuntimeException(e);
				}
			} try {
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e) {
					throw new RuntimeException(e);
				} catch (IOException e) {
					throw new RuntimeException(e);
				} IOException e {
					throw new RuntimeException(e);
				} throw new RuntimeException(e); new RuntimeException(e) {
					st = new StringTokenizer(br.readLine());
				} st = new StringTokenizer(br.readLine()) st new StringTokenizer(br.readLine()) return st.nextToken(); st.nextToken() st.nextToken st public class Main {
	
	public static void main(String[] args) {
		InputReader in = new InputReader();
		String str = in.next();
		
		String res = "";
		for (int i=0; i<str.length(); i++) {
			if (str.charAt(i) == 'B') {
				if (res.length() != 0)
					res = res.substring(0, res.length()-1);
			}
			else
				res += str.charAt(i);
		}
		System.out.println(res);
	}

	static class InputReader {
		public BufferedReader br;
		public StringTokenizer st;
		
		public InputReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
			st = null;
		}
		
		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}
	}
} public class Main {
	
	public static void main(String[] args) {
		InputReader in = new InputReader();
		String str = in.next();
		
		String res = "";
		for (int i=0; i<str.length(); i++) {
			if (str.charAt(i) == 'B') {
				if (res.length() != 0)
					res = res.substring(0, res.length()-1);
			}
			else
				res += str.charAt(i);
		}
		System.out.println(res);
	}

	static class InputReader {
		public BufferedReader br;
		public StringTokenizer st;
		
		public InputReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
			st = null;
		}
		
		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}
	}
} Main
import java.io.*;
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
		InputReader in = new InputReader();
		String str = in.next();
		
		String res = "";
		for (int i=0; i<str.length(); i++) {
			if (str.charAt(i) == 'B') {
				if (res.length() != 0)
					res = res.substring(0, res.length()-1);
			}
			else
				res += str.charAt(i);
		}
		System.out.println(res);
	}

	static class InputReader {
		public BufferedReader br;
		public StringTokenizer st;
		
		public InputReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
			st = null;
		}
		
		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}
	}
}