import java.util.Arrays;
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		String s = keyboard.next();
		
		String[] command = new String[s.length()];
		String[] result = new String[s.length()];
		
		for(int i = 0; i < s.length(); i ++) {
			command[i] = s.substring(i, i+1);
		}
		
		int jj = 0;
		int count = 1;
		
			for(int j = s.length() - 1; j >= 0; j--) {
				if(command[j].equals("B")){
					while(j != 0 && command[j-1].equals("B")){
						//一個前がBじゃないか調べる
						count ++;
						j--;
					}
					j -= count;
				}else {
					result[jj] = command[j];
					jj++;
				}
			}

		for(int k = jj - 1; k>=0; k --) {
			System.out.print(result[k]);
		}

		keyboard.close();	
	}
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		String s = keyboard.next();
		
		String[] command = new String[s.length()];
		String[] result = new String[s.length()];
		
		for(int i = 0; i < s.length(); i ++) {
			command[i] = s.substring(i, i+1);
		}
		
		int jj = 0;
		int count = 1;
		
			for(int j = s.length() - 1; j >= 0; j--) {
				if(command[j].equals("B")){
					while(j != 0 && command[j-1].equals("B")){
						//一個前がBじゃないか調べる
						count ++;
						j--;
					}
					j -= count;
				}else {
					result[jj] = command[j];
					jj++;
				}
			}

		for(int k = jj - 1; k>=0; k --) {
			System.out.print(result[k]);
		}

		keyboard.close();	
	}
} Main public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		String s = keyboard.next();
		
		String[] command = new String[s.length()];
		String[] result = new String[s.length()];
		
		for(int i = 0; i < s.length(); i ++) {
			command[i] = s.substring(i, i+1);
		}
		
		int jj = 0;
		int count = 1;
		
			for(int j = s.length() - 1; j >= 0; j--) {
				if(command[j].equals("B")){
					while(j != 0 && command[j-1].equals("B")){
						//一個前がBじゃないか調べる
						count ++;
						j--;
					}
					j -= count;
				}else {
					result[jj] = command[j];
					jj++;
				}
			}

		for(int k = jj - 1; k>=0; k --) {
			System.out.print(result[k]);
		}

		keyboard.close();	
	} main {
		
		Scanner keyboard = new Scanner(System.in); 
		
		String s = keyboard.next();
		
		String[] command = new String[s.length()];
		String[] result = new String[s.length()];
		
		for(int i = 0; i < s.length(); i ++) {
			command[i] = s.substring(i, i+1);
		}
		
		int jj = 0;
		int count = 1;
		
			for(int j = s.length() - 1; j >= 0; j--) {
				if(command[j].equals("B")){
					while(j != 0 && command[j-1].equals("B")){
						//一個前がBじゃないか調べる
						count ++;
						j--;
					}
					j -= count;
				}else {
					result[jj] = command[j];
					jj++;
				}
			}

		for(int k = jj - 1; k>=0; k --) {
			System.out.print(result[k]);
		}

		keyboard.close();	
	} Scanner keyboard = new Scanner(System.in); keyboard new Scanner(System.in) String s = keyboard.next(); s keyboard.next() keyboard.next keyboard String[] command = new String[s.length()]; command new String[s.length()] s.length() s.length s String[] result = new String[s.length()]; result new String[s.length()] s.length() s.length s for(int i = 0; i < s.length(); i ++) {
			command[i] = s.substring(i, i+1);
		} int i = 0; int i = 0; i 0 i < s.length() i s.length() s.length s i ++ i ++ i {
			command[i] = s.substring(i, i+1);
		} {
			command[i] = s.substring(i, i+1);
		} command[i] = s.substring(i, i+1) command[i] command i s.substring(i, i+1) s.substring s i i+1 i 1 int jj = 0; jj 0 int count = 1; count 1 for(int j = s.length() - 1; j >= 0; j--) {
				if(command[j].equals("B")){
					while(j != 0 && command[j-1].equals("B")){
						//一個前がBじゃないか調べる
						count ++;
						j--;
					}
					j -= count;
				}else {
					result[jj] = command[j];
					jj++;
				}
			} int j = s.length() - 1; int j = s.length() - 1; j s.length() - 1 s.length() s.length s 1 j >= 0 j 0 j-- j-- j {
				if(command[j].equals("B")){
					while(j != 0 && command[j-1].equals("B")){
						//一個前がBじゃないか調べる
						count ++;
						j--;
					}
					j -= count;
				}else {
					result[jj] = command[j];
					jj++;
				}
			} {
				if(command[j].equals("B")){
					while(j != 0 && command[j-1].equals("B")){
						//一個前がBじゃないか調べる
						count ++;
						j--;
					}
					j -= count;
				}else {
					result[jj] = command[j];
					jj++;
				}
			} if(command[j].equals("B")){
					while(j != 0 && command[j-1].equals("B")){
						//一個前がBじゃないか調べる
						count ++;
						j--;
					}
					j -= count;
				}else {
					result[jj] = command[j];
					jj++;
				} command[j].equals("B") command[j].equals command[j] command j "B" {
					while(j != 0 && command[j-1].equals("B")){
						//一個前がBじゃないか調べる
						count ++;
						j--;
					}
					j -= count;
				} while(j != 0 && command[j-1].equals("B")){
						//一個前がBじゃないか調べる
						count ++;
						j--;
					} j != 0 && command[j-1].equals("B") j != 0 j 0 command[j-1].equals("B") command[j-1].equals command[j-1] command j-1 j 1 "B" {
						//一個前がBじゃないか調べる
						count ++;
						j--;
					} count ++ count j-- j j -= count j count {
					result[jj] = command[j];
					jj++;
				} result[jj] = command[j] result[jj] result jj command[j] command j jj++ jj for(int k = jj - 1; k>=0; k --) {
			System.out.print(result[k]);
		} int k = jj - 1; int k = jj - 1; k jj - 1 jj 1 k>=0 k 0 k -- k -- k {
			System.out.print(result[k]);
		} {
			System.out.print(result[k]);
		} System.out.print(result[k]) System.out.print System.out System System.out result[k] result k keyboard.close() keyboard.close keyboard String[] args args public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		String s = keyboard.next();
		
		String[] command = new String[s.length()];
		String[] result = new String[s.length()];
		
		for(int i = 0; i < s.length(); i ++) {
			command[i] = s.substring(i, i+1);
		}
		
		int jj = 0;
		int count = 1;
		
			for(int j = s.length() - 1; j >= 0; j--) {
				if(command[j].equals("B")){
					while(j != 0 && command[j-1].equals("B")){
						//一個前がBじゃないか調べる
						count ++;
						j--;
					}
					j -= count;
				}else {
					result[jj] = command[j];
					jj++;
				}
			}

		for(int k = jj - 1; k>=0; k --) {
			System.out.print(result[k]);
		}

		keyboard.close();	
	}
} public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		String s = keyboard.next();
		
		String[] command = new String[s.length()];
		String[] result = new String[s.length()];
		
		for(int i = 0; i < s.length(); i ++) {
			command[i] = s.substring(i, i+1);
		}
		
		int jj = 0;
		int count = 1;
		
			for(int j = s.length() - 1; j >= 0; j--) {
				if(command[j].equals("B")){
					while(j != 0 && command[j-1].equals("B")){
						//一個前がBじゃないか調べる
						count ++;
						j--;
					}
					j -= count;
				}else {
					result[jj] = command[j];
					jj++;
				}
			}

		for(int k = jj - 1; k>=0; k --) {
			System.out.print(result[k]);
		}

		keyboard.close();	
	}
} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		String s = keyboard.next();
		
		String[] command = new String[s.length()];
		String[] result = new String[s.length()];
		
		for(int i = 0; i < s.length(); i ++) {
			command[i] = s.substring(i, i+1);
		}
		
		int jj = 0;
		int count = 1;
		
			for(int j = s.length() - 1; j >= 0; j--) {
				if(command[j].equals("B")){
					while(j != 0 && command[j-1].equals("B")){
						//一個前がBじゃないか調べる
						count ++;
						j--;
					}
					j -= count;
				}else {
					result[jj] = command[j];
					jj++;
				}
			}

		for(int k = jj - 1; k>=0; k --) {
			System.out.print(result[k]);
		}

		keyboard.close();	
	}
}