import java.util.*;

public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);

    String s = sc.next();

    String a = "";
    int n = 0;
    for (int i = 0; i < s.length(); i++) {
      String t = s.substring(i, i+1);
      if (t.equals("B") && a.length() == 0) continue;
      if (t.equals("B") && a.length() != 0) {
        a = a.substring(0, n-1);
        n--;
      } else {
        a += t;
        n++;
      }
    }
    
    System.out.println(a);
  }
} import java.util.*; util.* java public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);

    String s = sc.next();

    String a = "";
    int n = 0;
    for (int i = 0; i < s.length(); i++) {
      String t = s.substring(i, i+1);
      if (t.equals("B") && a.length() == 0) continue;
      if (t.equals("B") && a.length() != 0) {
        a = a.substring(0, n-1);
        n--;
      } else {
        a += t;
        n++;
      }
    }
    
    System.out.println(a);
  }
} Main public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);

    String s = sc.next();

    String a = "";
    int n = 0;
    for (int i = 0; i < s.length(); i++) {
      String t = s.substring(i, i+1);
      if (t.equals("B") && a.length() == 0) continue;
      if (t.equals("B") && a.length() != 0) {
        a = a.substring(0, n-1);
        n--;
      } else {
        a += t;
        n++;
      }
    }
    
    System.out.println(a);
  } main {
    Scanner sc = new Scanner(System.in);

    String s = sc.next();

    String a = "";
    int n = 0;
    for (int i = 0; i < s.length(); i++) {
      String t = s.substring(i, i+1);
      if (t.equals("B") && a.length() == 0) continue;
      if (t.equals("B") && a.length() != 0) {
        a = a.substring(0, n-1);
        n--;
      } else {
        a += t;
        n++;
      }
    }
    
    System.out.println(a);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc String a = ""; a "" int n = 0; n 0 for (int i = 0; i < s.length(); i++) {
      String t = s.substring(i, i+1);
      if (t.equals("B") && a.length() == 0) continue;
      if (t.equals("B") && a.length() != 0) {
        a = a.substring(0, n-1);
        n--;
      } else {
        a += t;
        n++;
      }
    } int i = 0; int i = 0; i 0 i < s.length() i s.length() s.length s i++ i++ i {
      String t = s.substring(i, i+1);
      if (t.equals("B") && a.length() == 0) continue;
      if (t.equals("B") && a.length() != 0) {
        a = a.substring(0, n-1);
        n--;
      } else {
        a += t;
        n++;
      }
    } {
      String t = s.substring(i, i+1);
      if (t.equals("B") && a.length() == 0) continue;
      if (t.equals("B") && a.length() != 0) {
        a = a.substring(0, n-1);
        n--;
      } else {
        a += t;
        n++;
      }
    } String t = s.substring(i, i+1); t s.substring(i, i+1) s.substring s i i+1 i 1 if (t.equals("B") && a.length() == 0) continue; t.equals("B") && a.length() == 0 t.equals("B") t.equals t "B" a.length() == 0 a.length() a.length a 0 continue; if (t.equals("B") && a.length() != 0) {
        a = a.substring(0, n-1);
        n--;
      } else {
        a += t;
        n++;
      } t.equals("B") && a.length() != 0 t.equals("B") t.equals t "B" a.length() != 0 a.length() a.length a 0 {
        a = a.substring(0, n-1);
        n--;
      } a = a.substring(0, n-1) a a.substring(0, n-1) a.substring a 0 n-1 n 1 n-- n {
        a += t;
        n++;
      } a += t a t n++ n System.out.println(a) System.out.println System.out System System.out a String[] args args public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);

    String s = sc.next();

    String a = "";
    int n = 0;
    for (int i = 0; i < s.length(); i++) {
      String t = s.substring(i, i+1);
      if (t.equals("B") && a.length() == 0) continue;
      if (t.equals("B") && a.length() != 0) {
        a = a.substring(0, n-1);
        n--;
      } else {
        a += t;
        n++;
      }
    }
    
    System.out.println(a);
  }
} public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);

    String s = sc.next();

    String a = "";
    int n = 0;
    for (int i = 0; i < s.length(); i++) {
      String t = s.substring(i, i+1);
      if (t.equals("B") && a.length() == 0) continue;
      if (t.equals("B") && a.length() != 0) {
        a = a.substring(0, n-1);
        n--;
      } else {
        a += t;
        n++;
      }
    }
    
    System.out.println(a);
  }
} Main
import java.util.*;

public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);

    String s = sc.next();

    String a = "";
    int n = 0;
    for (int i = 0; i < s.length(); i++) {
      String t = s.substring(i, i+1);
      if (t.equals("B") && a.length() == 0) continue;
      if (t.equals("B") && a.length() != 0) {
        a = a.substring(0, n-1);
        n--;
      } else {
        a += t;
        n++;
      }
    }
    
    System.out.println(a);
  }
}