import java.util.*;

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

class Solver {

    public void run() {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        StringBuffer b = new StringBuffer();
        for (int i = 0; i < s.length; i++) {
            char ch = s[i];
            int len = b.length();
            if (ch == 'B' && len > 0) {
                b.deleteCharAt(len - 1);
            } if (ch == 'B') {
            } else {
                b.append(ch);
            }
        }
        System.out.println(b.toString());
        return;
    }

} import java.util.*; util.* java class Main {
    public static void main(String[] args) {
        new Solver().run();
    }
} Main public static void main(String[] args) {
        new Solver().run();
    } main {
        new Solver().run();
    } new Solver().run() new Solver().run new Solver() String[] args args class Solver {

    public void run() {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        StringBuffer b = new StringBuffer();
        for (int i = 0; i < s.length; i++) {
            char ch = s[i];
            int len = b.length();
            if (ch == 'B' && len > 0) {
                b.deleteCharAt(len - 1);
            } if (ch == 'B') {
            } else {
                b.append(ch);
            }
        }
        System.out.println(b.toString());
        return;
    }

} Solver public void run() {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        StringBuffer b = new StringBuffer();
        for (int i = 0; i < s.length; i++) {
            char ch = s[i];
            int len = b.length();
            if (ch == 'B' && len > 0) {
                b.deleteCharAt(len - 1);
            } if (ch == 'B') {
            } else {
                b.append(ch);
            }
        }
        System.out.println(b.toString());
        return;
    } run {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        StringBuffer b = new StringBuffer();
        for (int i = 0; i < s.length; i++) {
            char ch = s[i];
            int len = b.length();
            if (ch == 'B' && len > 0) {
                b.deleteCharAt(len - 1);
            } if (ch == 'B') {
            } else {
                b.append(ch);
            }
        }
        System.out.println(b.toString());
        return;
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) char[] s = sc.next().toCharArray(); s sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc StringBuffer b = new StringBuffer(); b new StringBuffer() for (int i = 0; i < s.length; i++) {
            char ch = s[i];
            int len = b.length();
            if (ch == 'B' && len > 0) {
                b.deleteCharAt(len - 1);
            } if (ch == 'B') {
            } else {
                b.append(ch);
            }
        } int i = 0; int i = 0; i 0 i < s.length i s.length s s.length i++ i++ i {
            char ch = s[i];
            int len = b.length();
            if (ch == 'B' && len > 0) {
                b.deleteCharAt(len - 1);
            } if (ch == 'B') {
            } else {
                b.append(ch);
            }
        } {
            char ch = s[i];
            int len = b.length();
            if (ch == 'B' && len > 0) {
                b.deleteCharAt(len - 1);
            } if (ch == 'B') {
            } else {
                b.append(ch);
            }
        } char ch = s[i]; ch s[i] s i int len = b.length(); len b.length() b.length b if (ch == 'B' && len > 0) {
                b.deleteCharAt(len - 1);
            } ch == 'B' && len > 0 ch == 'B' ch 'B' len > 0 len 0 {
                b.deleteCharAt(len - 1);
            } b.deleteCharAt(len - 1) b.deleteCharAt b len - 1 len 1 if (ch == 'B') {
            } else {
                b.append(ch);
            } ch == 'B' ch 'B' {
            } {
                b.append(ch);
            } b.append(ch) b.append b ch System.out.println(b.toString()) System.out.println System.out System System.out b.toString() b.toString b return;
import java.util.*;

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

class Solver {

    public void run() {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        StringBuffer b = new StringBuffer();
        for (int i = 0; i < s.length; i++) {
            char ch = s[i];
            int len = b.length();
            if (ch == 'B' && len > 0) {
                b.deleteCharAt(len - 1);
            } if (ch == 'B') {
            } else {
                b.append(ch);
            }
        }
        System.out.println(b.toString());
        return;
    }

}