import java.util.*;
import java.util.stream.Collectors;

/**
 * ABC043 B
 *
 * @date 2020.08.22
 * @author 焼き鮭 <yaki-shake@up-tri.me>
 */

public class Main {
  Scanner sc;

  public static void main(String[] args) {
    new Main().execute();
  }

  public void execute() {
    this.sc = new Scanner(System.in);
    String commands = this.sc.next();
    String[] keys = commands.split("");
    ArrayList<String> output = new ArrayList<String>();
    for (String key : keys) {
      if (key.equals("B")) {
        if (0 < output.size()) {
          output.remove(output.size() - 1);
        }
      } else {
        output.add(key);
      }
    }

    System.out.println(output.stream().collect(Collectors.joining("")));
  }
} import java.util.*; util.* java import java.util.stream.Collectors; Collectors java.util.stream public class Main {
  Scanner sc;

  public static void main(String[] args) {
    new Main().execute();
  }

  public void execute() {
    this.sc = new Scanner(System.in);
    String commands = this.sc.next();
    String[] keys = commands.split("");
    ArrayList<String> output = new ArrayList<String>();
    for (String key : keys) {
      if (key.equals("B")) {
        if (0 < output.size()) {
          output.remove(output.size() - 1);
        }
      } else {
        output.add(key);
      }
    }

    System.out.println(output.stream().collect(Collectors.joining("")));
  }
} Main Scanner sc; sc public static void main(String[] args) {
    new Main().execute();
  } main {
    new Main().execute();
  } new Main().execute() new Main().execute new Main() String[] args args public void execute() {
    this.sc = new Scanner(System.in);
    String commands = this.sc.next();
    String[] keys = commands.split("");
    ArrayList<String> output = new ArrayList<String>();
    for (String key : keys) {
      if (key.equals("B")) {
        if (0 < output.size()) {
          output.remove(output.size() - 1);
        }
      } else {
        output.add(key);
      }
    }

    System.out.println(output.stream().collect(Collectors.joining("")));
  } execute {
    this.sc = new Scanner(System.in);
    String commands = this.sc.next();
    String[] keys = commands.split("");
    ArrayList<String> output = new ArrayList<String>();
    for (String key : keys) {
      if (key.equals("B")) {
        if (0 < output.size()) {
          output.remove(output.size() - 1);
        }
      } else {
        output.add(key);
      }
    }

    System.out.println(output.stream().collect(Collectors.joining("")));
  } this.sc = new Scanner(System.in) this.sc this this.sc new Scanner(System.in) String commands = this.sc.next(); commands this.sc.next() this.sc.next this.sc this this.sc String[] keys = commands.split(""); keys commands.split("") commands.split commands "" ArrayList<String> output = new ArrayList<String>(); output new ArrayList<String>() for (String key : keys) {
      if (key.equals("B")) {
        if (0 < output.size()) {
          output.remove(output.size() - 1);
        }
      } else {
        output.add(key);
      }
    } String key keys {
      if (key.equals("B")) {
        if (0 < output.size()) {
          output.remove(output.size() - 1);
        }
      } else {
        output.add(key);
      }
    } {
      if (key.equals("B")) {
        if (0 < output.size()) {
          output.remove(output.size() - 1);
        }
      } else {
        output.add(key);
      }
    } if (key.equals("B")) {
        if (0 < output.size()) {
          output.remove(output.size() - 1);
        }
      } else {
        output.add(key);
      } key.equals("B") key.equals key "B" {
        if (0 < output.size()) {
          output.remove(output.size() - 1);
        }
      } if (0 < output.size()) {
          output.remove(output.size() - 1);
        } 0 < output.size() 0 output.size() output.size output {
          output.remove(output.size() - 1);
        } output.remove(output.size() - 1) output.remove output output.size() - 1 output.size() output.size output 1 {
        output.add(key);
      } output.add(key) output.add output key System.out.println(output.stream().collect(Collectors.joining(""))) System.out.println System.out System System.out output.stream().collect(Collectors.joining("")) output.stream().collect output.stream() output.stream output Collectors.joining("") Collectors.joining Collectors "" public class Main {
  Scanner sc;

  public static void main(String[] args) {
    new Main().execute();
  }

  public void execute() {
    this.sc = new Scanner(System.in);
    String commands = this.sc.next();
    String[] keys = commands.split("");
    ArrayList<String> output = new ArrayList<String>();
    for (String key : keys) {
      if (key.equals("B")) {
        if (0 < output.size()) {
          output.remove(output.size() - 1);
        }
      } else {
        output.add(key);
      }
    }

    System.out.println(output.stream().collect(Collectors.joining("")));
  }
} public class Main {
  Scanner sc;

  public static void main(String[] args) {
    new Main().execute();
  }

  public void execute() {
    this.sc = new Scanner(System.in);
    String commands = this.sc.next();
    String[] keys = commands.split("");
    ArrayList<String> output = new ArrayList<String>();
    for (String key : keys) {
      if (key.equals("B")) {
        if (0 < output.size()) {
          output.remove(output.size() - 1);
        }
      } else {
        output.add(key);
      }
    }

    System.out.println(output.stream().collect(Collectors.joining("")));
  }
} Main
import java.util.*;
import java.util.stream.Collectors;

/**
 * ABC043 B
 *
 * @date 2020.08.22
 * @author 焼き鮭 <yaki-shake@up-tri.me>
 */

public class Main {
  Scanner sc;

  public static void main(String[] args) {
    new Main().execute();
  }

  public void execute() {
    this.sc = new Scanner(System.in);
    String commands = this.sc.next();
    String[] keys = commands.split("");
    ArrayList<String> output = new ArrayList<String>();
    for (String key : keys) {
      if (key.equals("B")) {
        if (0 < output.size()) {
          output.remove(output.size() - 1);
        }
      } else {
        output.add(key);
      }
    }

    System.out.println(output.stream().collect(Collectors.joining("")));
  }
}
