import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Stack;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String str = br.readLine();
    Stack<String> stack = new Stack<String>();
    for (int i = 0; i < str.length(); i++) {
      if (str.charAt(i) == 'B' && !stack.empty()) {
        stack.pop();
      } else if (str.charAt(i) != 'B') {
        stack.push(String.valueOf(str.charAt(i)));
      }
    }
    System.out.println(String.join("",stack));
  }
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.io.IOException; IOException java.io import java.util.Stack; Stack java.util public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String str = br.readLine();
    Stack<String> stack = new Stack<String>();
    for (int i = 0; i < str.length(); i++) {
      if (str.charAt(i) == 'B' && !stack.empty()) {
        stack.pop();
      } else if (str.charAt(i) != 'B') {
        stack.push(String.valueOf(str.charAt(i)));
      }
    }
    System.out.println(String.join("",stack));
  }
} Main public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String str = br.readLine();
    Stack<String> stack = new Stack<String>();
    for (int i = 0; i < str.length(); i++) {
      if (str.charAt(i) == 'B' && !stack.empty()) {
        stack.pop();
      } else if (str.charAt(i) != 'B') {
        stack.push(String.valueOf(str.charAt(i)));
      }
    }
    System.out.println(String.join("",stack));
  } main {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String str = br.readLine();
    Stack<String> stack = new Stack<String>();
    for (int i = 0; i < str.length(); i++) {
      if (str.charAt(i) == 'B' && !stack.empty()) {
        stack.pop();
      } else if (str.charAt(i) != 'B') {
        stack.push(String.valueOf(str.charAt(i)));
      }
    }
    System.out.println(String.join("",stack));
  } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String str = br.readLine(); str br.readLine() br.readLine br Stack<String> stack = new Stack<String>(); stack new Stack<String>() for (int i = 0; i < str.length(); i++) {
      if (str.charAt(i) == 'B' && !stack.empty()) {
        stack.pop();
      } else if (str.charAt(i) != 'B') {
        stack.push(String.valueOf(str.charAt(i)));
      }
    } int i = 0; int i = 0; i 0 i < str.length() i str.length() str.length str i++ i++ i {
      if (str.charAt(i) == 'B' && !stack.empty()) {
        stack.pop();
      } else if (str.charAt(i) != 'B') {
        stack.push(String.valueOf(str.charAt(i)));
      }
    } {
      if (str.charAt(i) == 'B' && !stack.empty()) {
        stack.pop();
      } else if (str.charAt(i) != 'B') {
        stack.push(String.valueOf(str.charAt(i)));
      }
    } if (str.charAt(i) == 'B' && !stack.empty()) {
        stack.pop();
      } else if (str.charAt(i) != 'B') {
        stack.push(String.valueOf(str.charAt(i)));
      } str.charAt(i) == 'B' && !stack.empty() str.charAt(i) == 'B' str.charAt(i) str.charAt str i 'B' !stack.empty() stack.empty() stack.empty stack {
        stack.pop();
      } stack.pop() stack.pop stack if (str.charAt(i) != 'B') {
        stack.push(String.valueOf(str.charAt(i)));
      } str.charAt(i) != 'B' str.charAt(i) str.charAt str i 'B' {
        stack.push(String.valueOf(str.charAt(i)));
      } stack.push(String.valueOf(str.charAt(i))) stack.push stack String.valueOf(str.charAt(i)) String.valueOf String str.charAt(i) str.charAt str i System.out.println(String.join("",stack)) System.out.println System.out System System.out String.join("",stack) String.join String "" stack String[] args args public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String str = br.readLine();
    Stack<String> stack = new Stack<String>();
    for (int i = 0; i < str.length(); i++) {
      if (str.charAt(i) == 'B' && !stack.empty()) {
        stack.pop();
      } else if (str.charAt(i) != 'B') {
        stack.push(String.valueOf(str.charAt(i)));
      }
    }
    System.out.println(String.join("",stack));
  }
} public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String str = br.readLine();
    Stack<String> stack = new Stack<String>();
    for (int i = 0; i < str.length(); i++) {
      if (str.charAt(i) == 'B' && !stack.empty()) {
        stack.pop();
      } else if (str.charAt(i) != 'B') {
        stack.push(String.valueOf(str.charAt(i)));
      }
    }
    System.out.println(String.join("",stack));
  }
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Stack;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String str = br.readLine();
    Stack<String> stack = new Stack<String>();
    for (int i = 0; i < str.length(); i++) {
      if (str.charAt(i) == 'B' && !stack.empty()) {
        stack.pop();
      } else if (str.charAt(i) != 'B') {
        stack.push(String.valueOf(str.charAt(i)));
      }
    }
    System.out.println(String.join("",stack));
  }
}