
import java.util.*; 
public class Main {
    public static void main(String[] args)  {
      Scanner in = new Scanner(System.in);
           String s = in.next();
           Stack<Character> st = new Stack<Character>();
           for (int i =0;i<s.length();i++) {
        	   if (s.charAt(i) == 'B' && st.size()!=0) {
        		   st.pop();}
        	   else if (s.charAt(i) != 'B'){
        		   st.push(s.charAt(i));
        	   }
           }
           for (Character ch : st) {
			System.out.print(ch);
		}
           System.out.println();
           
    }
 
} import java.util.*; util.* java public class Main {
    public static void main(String[] args)  {
      Scanner in = new Scanner(System.in);
           String s = in.next();
           Stack<Character> st = new Stack<Character>();
           for (int i =0;i<s.length();i++) {
        	   if (s.charAt(i) == 'B' && st.size()!=0) {
        		   st.pop();}
        	   else if (s.charAt(i) != 'B'){
        		   st.push(s.charAt(i));
        	   }
           }
           for (Character ch : st) {
			System.out.print(ch);
		}
           System.out.println();
           
    }
 
} Main public static void main(String[] args)  {
      Scanner in = new Scanner(System.in);
           String s = in.next();
           Stack<Character> st = new Stack<Character>();
           for (int i =0;i<s.length();i++) {
        	   if (s.charAt(i) == 'B' && st.size()!=0) {
        		   st.pop();}
        	   else if (s.charAt(i) != 'B'){
        		   st.push(s.charAt(i));
        	   }
           }
           for (Character ch : st) {
			System.out.print(ch);
		}
           System.out.println();
           
    } main {
      Scanner in = new Scanner(System.in);
           String s = in.next();
           Stack<Character> st = new Stack<Character>();
           for (int i =0;i<s.length();i++) {
        	   if (s.charAt(i) == 'B' && st.size()!=0) {
        		   st.pop();}
        	   else if (s.charAt(i) != 'B'){
        		   st.push(s.charAt(i));
        	   }
           }
           for (Character ch : st) {
			System.out.print(ch);
		}
           System.out.println();
           
    } Scanner in = new Scanner(System.in); in new Scanner(System.in) String s = in.next(); s in.next() in.next in Stack<Character> st = new Stack<Character>(); st new Stack<Character>() for (int i =0;i<s.length();i++) {
        	   if (s.charAt(i) == 'B' && st.size()!=0) {
        		   st.pop();}
        	   else if (s.charAt(i) != 'B'){
        		   st.push(s.charAt(i));
        	   }
           } int i =0; int i =0; i 0 i<s.length() i s.length() s.length s i++ i++ i {
        	   if (s.charAt(i) == 'B' && st.size()!=0) {
        		   st.pop();}
        	   else if (s.charAt(i) != 'B'){
        		   st.push(s.charAt(i));
        	   }
           } {
        	   if (s.charAt(i) == 'B' && st.size()!=0) {
        		   st.pop();}
        	   else if (s.charAt(i) != 'B'){
        		   st.push(s.charAt(i));
        	   }
           } if (s.charAt(i) == 'B' && st.size()!=0) {
        		   st.pop();}
        	   else if (s.charAt(i) != 'B'){
        		   st.push(s.charAt(i));
        	   } s.charAt(i) == 'B' && st.size()!=0 s.charAt(i) == 'B' s.charAt(i) s.charAt s i 'B' st.size()!=0 st.size() st.size st 0 {
        		   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 s i for (Character ch : st) {
			System.out.print(ch);
		} Character ch st {
			System.out.print(ch);
		} {
			System.out.print(ch);
		} System.out.print(ch) System.out.print System.out System System.out ch System.out.println() System.out.println System.out System System.out String[] args args public class Main {
    public static void main(String[] args)  {
      Scanner in = new Scanner(System.in);
           String s = in.next();
           Stack<Character> st = new Stack<Character>();
           for (int i =0;i<s.length();i++) {
        	   if (s.charAt(i) == 'B' && st.size()!=0) {
        		   st.pop();}
        	   else if (s.charAt(i) != 'B'){
        		   st.push(s.charAt(i));
        	   }
           }
           for (Character ch : st) {
			System.out.print(ch);
		}
           System.out.println();
           
    }
 
} public class Main {
    public static void main(String[] args)  {
      Scanner in = new Scanner(System.in);
           String s = in.next();
           Stack<Character> st = new Stack<Character>();
           for (int i =0;i<s.length();i++) {
        	   if (s.charAt(i) == 'B' && st.size()!=0) {
        		   st.pop();}
        	   else if (s.charAt(i) != 'B'){
        		   st.push(s.charAt(i));
        	   }
           }
           for (Character ch : st) {
			System.out.print(ch);
		}
           System.out.println();
           
    }
 
} Main

import java.util.*; 
public class Main {
    public static void main(String[] args)  {
      Scanner in = new Scanner(System.in);
           String s = in.next();
           Stack<Character> st = new Stack<Character>();
           for (int i =0;i<s.length();i++) {
        	   if (s.charAt(i) == 'B' && st.size()!=0) {
        		   st.pop();}
        	   else if (s.charAt(i) != 'B'){
        		   st.push(s.charAt(i));
        	   }
           }
           for (Character ch : st) {
			System.out.print(ch);
		}
           System.out.println();
           
    }
 
}