import java.util.*;
public class Main {

  public static void main(String[] args) {
   Scanner no=new Scanner(System.in);
   StringBuilder sb=new StringBuilder();
   Stack<Character> st=new Stack<Character>();
   String s=no.next();
   for(int i=0;i<s.length();i++){
       if(s.charAt(i)=='B'){
        if(st.isEmpty()){
          continue;
        }
        else
         st.pop();
       }
       else{
         //System.out.println(s.charAt(i));
         st.push(s.charAt(i));
       }
   }
   for(int i=st.size()-1;i>=0;i--){
     sb.append(st.pop());
   }
   System.out.println(sb.reverse());
  }

} import java.util.*; util.* java public class Main {

  public static void main(String[] args) {
   Scanner no=new Scanner(System.in);
   StringBuilder sb=new StringBuilder();
   Stack<Character> st=new Stack<Character>();
   String s=no.next();
   for(int i=0;i<s.length();i++){
       if(s.charAt(i)=='B'){
        if(st.isEmpty()){
          continue;
        }
        else
         st.pop();
       }
       else{
         //System.out.println(s.charAt(i));
         st.push(s.charAt(i));
       }
   }
   for(int i=st.size()-1;i>=0;i--){
     sb.append(st.pop());
   }
   System.out.println(sb.reverse());
  }

} Main public static void main(String[] args) {
   Scanner no=new Scanner(System.in);
   StringBuilder sb=new StringBuilder();
   Stack<Character> st=new Stack<Character>();
   String s=no.next();
   for(int i=0;i<s.length();i++){
       if(s.charAt(i)=='B'){
        if(st.isEmpty()){
          continue;
        }
        else
         st.pop();
       }
       else{
         //System.out.println(s.charAt(i));
         st.push(s.charAt(i));
       }
   }
   for(int i=st.size()-1;i>=0;i--){
     sb.append(st.pop());
   }
   System.out.println(sb.reverse());
  } main {
   Scanner no=new Scanner(System.in);
   StringBuilder sb=new StringBuilder();
   Stack<Character> st=new Stack<Character>();
   String s=no.next();
   for(int i=0;i<s.length();i++){
       if(s.charAt(i)=='B'){
        if(st.isEmpty()){
          continue;
        }
        else
         st.pop();
       }
       else{
         //System.out.println(s.charAt(i));
         st.push(s.charAt(i));
       }
   }
   for(int i=st.size()-1;i>=0;i--){
     sb.append(st.pop());
   }
   System.out.println(sb.reverse());
  } Scanner no=new Scanner(System.in); no new Scanner(System.in) StringBuilder sb=new StringBuilder(); sb new StringBuilder() Stack<Character> st=new Stack<Character>(); st new Stack<Character>() String s=no.next(); s no.next() no.next no for(int i=0;i<s.length();i++){
       if(s.charAt(i)=='B'){
        if(st.isEmpty()){
          continue;
        }
        else
         st.pop();
       }
       else{
         //System.out.println(s.charAt(i));
         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'){
        if(st.isEmpty()){
          continue;
        }
        else
         st.pop();
       }
       else{
         //System.out.println(s.charAt(i));
         st.push(s.charAt(i));
       }
   } {
       if(s.charAt(i)=='B'){
        if(st.isEmpty()){
          continue;
        }
        else
         st.pop();
       }
       else{
         //System.out.println(s.charAt(i));
         st.push(s.charAt(i));
       }
   } if(s.charAt(i)=='B'){
        if(st.isEmpty()){
          continue;
        }
        else
         st.pop();
       }
       else{
         //System.out.println(s.charAt(i));
         st.push(s.charAt(i));
       } s.charAt(i)=='B' s.charAt(i) s.charAt s i 'B' {
        if(st.isEmpty()){
          continue;
        }
        else
         st.pop();
       } if(st.isEmpty()){
          continue;
        }
        else
         st.pop(); st.isEmpty() st.isEmpty st {
          continue;
        } continue; st.pop() st.pop st {
         //System.out.println(s.charAt(i));
         st.push(s.charAt(i));
       } st.push(s.charAt(i)) st.push st s.charAt(i) s.charAt s i for(int i=st.size()-1;i>=0;i--){
     sb.append(st.pop());
   } int i=st.size()-1; int i=st.size()-1; i st.size()-1 st.size() st.size st 1 i>=0 i 0 i-- i-- i {
     sb.append(st.pop());
   } {
     sb.append(st.pop());
   } sb.append(st.pop()) sb.append sb st.pop() st.pop st System.out.println(sb.reverse()) System.out.println System.out System System.out sb.reverse() sb.reverse sb String[] args args public class Main {

  public static void main(String[] args) {
   Scanner no=new Scanner(System.in);
   StringBuilder sb=new StringBuilder();
   Stack<Character> st=new Stack<Character>();
   String s=no.next();
   for(int i=0;i<s.length();i++){
       if(s.charAt(i)=='B'){
        if(st.isEmpty()){
          continue;
        }
        else
         st.pop();
       }
       else{
         //System.out.println(s.charAt(i));
         st.push(s.charAt(i));
       }
   }
   for(int i=st.size()-1;i>=0;i--){
     sb.append(st.pop());
   }
   System.out.println(sb.reverse());
  }

} public class Main {

  public static void main(String[] args) {
   Scanner no=new Scanner(System.in);
   StringBuilder sb=new StringBuilder();
   Stack<Character> st=new Stack<Character>();
   String s=no.next();
   for(int i=0;i<s.length();i++){
       if(s.charAt(i)=='B'){
        if(st.isEmpty()){
          continue;
        }
        else
         st.pop();
       }
       else{
         //System.out.println(s.charAt(i));
         st.push(s.charAt(i));
       }
   }
   for(int i=st.size()-1;i>=0;i--){
     sb.append(st.pop());
   }
   System.out.println(sb.reverse());
  }

} Main
import java.util.*;
public class Main {

  public static void main(String[] args) {
   Scanner no=new Scanner(System.in);
   StringBuilder sb=new StringBuilder();
   Stack<Character> st=new Stack<Character>();
   String s=no.next();
   for(int i=0;i<s.length();i++){
       if(s.charAt(i)=='B'){
        if(st.isEmpty()){
          continue;
        }
        else
         st.pop();
       }
       else{
         //System.out.println(s.charAt(i));
         st.push(s.charAt(i));
       }
   }
   for(int i=st.size()-1;i>=0;i--){
     sb.append(st.pop());
   }
   System.out.println(sb.reverse());
  }

}