/*package whatever //do not write package name here */

import java.io.*;
import java.io.BufferedReader; 
import java.io.IOException; 
import java.io.InputStreamReader; 
import java.util.Scanner; 
import java.util.StringTokenizer; 
import java.util.*;


class Main {
    static class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next(){
            while(st==null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }
                catch(IOException e){
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt(){
            return Integer.parseInt(next());
        }
    }
    
	public static void main (String[] args) {
		FastReader ob = new FastReader();
	    Stack<String> st = new Stack<String>();
	    String s = ob.next();
	    int n = s.length();
	    for (int i=0;i<n ;i++ ) {
	        if(s.charAt(i)=='B' && !st.empty()){
	            st.pop();
	        }
	        else if(s.charAt(i)!='B'){
	            st.push(""+s.charAt(i));
	        }
	    }
	    String ans ="";
	    while(!st.empty()){
	        ans = st.pop()+ans;
	    }
	    System.out.print(ans);
	    
	}
} import java.io.*; io.* java import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.Scanner; Scanner java.util import java.util.StringTokenizer; StringTokenizer java.util import java.util.*; util.* java class Main {
    static class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next(){
            while(st==null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }
                catch(IOException e){
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt(){
            return Integer.parseInt(next());
        }
    }
    
	public static void main (String[] args) {
		FastReader ob = new FastReader();
	    Stack<String> st = new Stack<String>();
	    String s = ob.next();
	    int n = s.length();
	    for (int i=0;i<n ;i++ ) {
	        if(s.charAt(i)=='B' && !st.empty()){
	            st.pop();
	        }
	        else if(s.charAt(i)!='B'){
	            st.push(""+s.charAt(i));
	        }
	    }
	    String ans ="";
	    while(!st.empty()){
	        ans = st.pop()+ans;
	    }
	    System.out.print(ans);
	    
	}
} Main public static void main (String[] args) {
		FastReader ob = new FastReader();
	    Stack<String> st = new Stack<String>();
	    String s = ob.next();
	    int n = s.length();
	    for (int i=0;i<n ;i++ ) {
	        if(s.charAt(i)=='B' && !st.empty()){
	            st.pop();
	        }
	        else if(s.charAt(i)!='B'){
	            st.push(""+s.charAt(i));
	        }
	    }
	    String ans ="";
	    while(!st.empty()){
	        ans = st.pop()+ans;
	    }
	    System.out.print(ans);
	    
	} main {
		FastReader ob = new FastReader();
	    Stack<String> st = new Stack<String>();
	    String s = ob.next();
	    int n = s.length();
	    for (int i=0;i<n ;i++ ) {
	        if(s.charAt(i)=='B' && !st.empty()){
	            st.pop();
	        }
	        else if(s.charAt(i)!='B'){
	            st.push(""+s.charAt(i));
	        }
	    }
	    String ans ="";
	    while(!st.empty()){
	        ans = st.pop()+ans;
	    }
	    System.out.print(ans);
	    
	} FastReader ob = new FastReader(); ob new FastReader() Stack<String> st = new Stack<String>(); st new Stack<String>() String s = ob.next(); s ob.next() ob.next ob int n = s.length(); n s.length() s.length s for (int i=0;i<n ;i++ ) {
	        if(s.charAt(i)=='B' && !st.empty()){
	            st.pop();
	        }
	        else if(s.charAt(i)!='B'){
	            st.push(""+s.charAt(i));
	        }
	    } int i=0; int i=0; i 0 i<n i n i++ i++ i {
	        if(s.charAt(i)=='B' && !st.empty()){
	            st.pop();
	        }
	        else if(s.charAt(i)!='B'){
	            st.push(""+s.charAt(i));
	        }
	    } {
	        if(s.charAt(i)=='B' && !st.empty()){
	            st.pop();
	        }
	        else if(s.charAt(i)!='B'){
	            st.push(""+s.charAt(i));
	        }
	    } if(s.charAt(i)=='B' && !st.empty()){
	            st.pop();
	        }
	        else if(s.charAt(i)!='B'){
	            st.push(""+s.charAt(i));
	        } s.charAt(i)=='B' && !st.empty() s.charAt(i)=='B' s.charAt(i) s.charAt s i 'B' !st.empty() st.empty() st.empty st {
	            st.pop();
	        } st.pop() st.pop st if(s.charAt(i)!='B'){
	            st.push(""+s.charAt(i));
	        } s.charAt(i)!='B' s.charAt(i) s.charAt s i 'B' {
	            st.push(""+s.charAt(i));
	        } st.push(""+s.charAt(i)) st.push st ""+s.charAt(i) "" s.charAt(i) s.charAt s i String ans =""; ans "" while(!st.empty()){
	        ans = st.pop()+ans;
	    } !st.empty() st.empty() st.empty st {
	        ans = st.pop()+ans;
	    } ans = st.pop()+ans ans st.pop()+ans st.pop() st.pop st ans System.out.print(ans) System.out.print System.out System System.out ans String[] args args static class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next(){
            while(st==null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }
                catch(IOException e){
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt(){
            return Integer.parseInt(next());
        }
    } FastReader BufferedReader br; br StringTokenizer st; st public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        } FastReader {
            br = new BufferedReader(new InputStreamReader(System.in));
        } br = new BufferedReader(new InputStreamReader(System.in)) br new BufferedReader(new InputStreamReader(System.in)) String next(){
            while(st==null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }
                catch(IOException e){
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        } next {
            while(st==null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }
                catch(IOException e){
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        } while(st==null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }
                catch(IOException e){
                    e.printStackTrace();
                }
            } st==null || !st.hasMoreTokens() st==null st null !st.hasMoreTokens() st.hasMoreTokens() st.hasMoreTokens st {
                try{
                    st = new StringTokenizer(br.readLine());
                }
                catch(IOException e){
                    e.printStackTrace();
                }
            } try{
                    st = new StringTokenizer(br.readLine());
                }
                catch(IOException e){
                    e.printStackTrace();
                } catch(IOException e){
                    e.printStackTrace();
                } IOException e {
                    e.printStackTrace();
                } e.printStackTrace() e.printStackTrace e {
                    st = new StringTokenizer(br.readLine());
                } st = new StringTokenizer(br.readLine()) st new StringTokenizer(br.readLine()) return st.nextToken(); st.nextToken() st.nextToken st int nextInt(){
            return Integer.parseInt(next());
        } nextInt {
            return Integer.parseInt(next());
        } return Integer.parseInt(next()); Integer.parseInt(next()) Integer.parseInt Integer next() next
/*package whatever //do not write package name here */

import java.io.*;
import java.io.BufferedReader; 
import java.io.IOException; 
import java.io.InputStreamReader; 
import java.util.Scanner; 
import java.util.StringTokenizer; 
import java.util.*;


class Main {
    static class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next(){
            while(st==null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }
                catch(IOException e){
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt(){
            return Integer.parseInt(next());
        }
    }
    
	public static void main (String[] args) {
		FastReader ob = new FastReader();
	    Stack<String> st = new Stack<String>();
	    String s = ob.next();
	    int n = s.length();
	    for (int i=0;i<n ;i++ ) {
	        if(s.charAt(i)=='B' && !st.empty()){
	            st.pop();
	        }
	        else if(s.charAt(i)!='B'){
	            st.push(""+s.charAt(i));
	        }
	    }
	    String ans ="";
	    while(!st.empty()){
	        ans = st.pop()+ans;
	    }
	    System.out.print(ans);
	    
	}
}