import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String sa = scanner.next();
        ArrayList<Character> list = new ArrayList<>();

        for(int i = 0; i<sa.length(); i++) {
            char c = sa.charAt(i);
            if(c=='B') {
                if (list.size() > 0) list.remove(list.size() - 1);
            }
            else list.add(c);
        }
        Character[] carray = list.toArray(new Character[list.size()]);
        for(char c: carray) System.out.print(c);
        System.out.println();

    }
} import java.util.*; util.* java class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String sa = scanner.next();
        ArrayList<Character> list = new ArrayList<>();

        for(int i = 0; i<sa.length(); i++) {
            char c = sa.charAt(i);
            if(c=='B') {
                if (list.size() > 0) list.remove(list.size() - 1);
            }
            else list.add(c);
        }
        Character[] carray = list.toArray(new Character[list.size()]);
        for(char c: carray) System.out.print(c);
        System.out.println();

    }
} Main public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String sa = scanner.next();
        ArrayList<Character> list = new ArrayList<>();

        for(int i = 0; i<sa.length(); i++) {
            char c = sa.charAt(i);
            if(c=='B') {
                if (list.size() > 0) list.remove(list.size() - 1);
            }
            else list.add(c);
        }
        Character[] carray = list.toArray(new Character[list.size()]);
        for(char c: carray) System.out.print(c);
        System.out.println();

    } main {
        Scanner scanner = new Scanner(System.in);
        String sa = scanner.next();
        ArrayList<Character> list = new ArrayList<>();

        for(int i = 0; i<sa.length(); i++) {
            char c = sa.charAt(i);
            if(c=='B') {
                if (list.size() > 0) list.remove(list.size() - 1);
            }
            else list.add(c);
        }
        Character[] carray = list.toArray(new Character[list.size()]);
        for(char c: carray) System.out.print(c);
        System.out.println();

    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) String sa = scanner.next(); sa scanner.next() scanner.next scanner ArrayList<Character> list = new ArrayList<>(); list new ArrayList<>() for(int i = 0; i<sa.length(); i++) {
            char c = sa.charAt(i);
            if(c=='B') {
                if (list.size() > 0) list.remove(list.size() - 1);
            }
            else list.add(c);
        } int i = 0; int i = 0; i 0 i<sa.length() i sa.length() sa.length sa i++ i++ i {
            char c = sa.charAt(i);
            if(c=='B') {
                if (list.size() > 0) list.remove(list.size() - 1);
            }
            else list.add(c);
        } {
            char c = sa.charAt(i);
            if(c=='B') {
                if (list.size() > 0) list.remove(list.size() - 1);
            }
            else list.add(c);
        } char c = sa.charAt(i); c sa.charAt(i) sa.charAt sa i if(c=='B') {
                if (list.size() > 0) list.remove(list.size() - 1);
            }
            else list.add(c); c=='B' c 'B' {
                if (list.size() > 0) list.remove(list.size() - 1);
            } if (list.size() > 0) list.remove(list.size() - 1); list.size() > 0 list.size() list.size list 0 list.remove(list.size() - 1) list.remove list list.size() - 1 list.size() list.size list 1 list.add(c) list.add list c Character[] carray = list.toArray(new Character[list.size()]); carray list.toArray(new Character[list.size()]) list.toArray list new Character[list.size()] list.size() list.size list for(char c: carray) System.out.print(c); char c carray System.out.print(c); System.out.print(c) System.out.print System.out System System.out c System.out.println() System.out.println System.out System System.out String[] args args
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String sa = scanner.next();
        ArrayList<Character> list = new ArrayList<>();

        for(int i = 0; i<sa.length(); i++) {
            char c = sa.charAt(i);
            if(c=='B') {
                if (list.size() > 0) list.remove(list.size() - 1);
            }
            else list.add(c);
        }
        Character[] carray = list.toArray(new Character[list.size()]);
        for(char c: carray) System.out.print(c);
        System.out.println();

    }
}