import java.util.Scanner;

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

        String s = sc.next();
        char[] ans = new char[s.length()];

        int index = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == 'B') {
                if (index > 0)
                    index--;
            } else {
                ans[index++] = s.charAt(i);
            }
        }

        for (int i = 0; i < index; i++) {
            System.out.print(ans[i]);
        }
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String s = sc.next();
        char[] ans = new char[s.length()];

        int index = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == 'B') {
                if (index > 0)
                    index--;
            } else {
                ans[index++] = s.charAt(i);
            }
        }

        for (int i = 0; i < index; i++) {
            System.out.print(ans[i]);
        }
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String s = sc.next();
        char[] ans = new char[s.length()];

        int index = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == 'B') {
                if (index > 0)
                    index--;
            } else {
                ans[index++] = s.charAt(i);
            }
        }

        for (int i = 0; i < index; i++) {
            System.out.print(ans[i]);
        }
    } main {
        Scanner sc = new Scanner(System.in);

        String s = sc.next();
        char[] ans = new char[s.length()];

        int index = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == 'B') {
                if (index > 0)
                    index--;
            } else {
                ans[index++] = s.charAt(i);
            }
        }

        for (int i = 0; i < index; i++) {
            System.out.print(ans[i]);
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc char[] ans = new char[s.length()]; ans new char[s.length()] s.length() s.length s int index = 0; index 0 for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == 'B') {
                if (index > 0)
                    index--;
            } else {
                ans[index++] = s.charAt(i);
            }
        } int i = 0; int i = 0; i 0 i < s.length() i s.length() s.length s i++ i++ i {
            if (s.charAt(i) == 'B') {
                if (index > 0)
                    index--;
            } else {
                ans[index++] = s.charAt(i);
            }
        } {
            if (s.charAt(i) == 'B') {
                if (index > 0)
                    index--;
            } else {
                ans[index++] = s.charAt(i);
            }
        } if (s.charAt(i) == 'B') {
                if (index > 0)
                    index--;
            } else {
                ans[index++] = s.charAt(i);
            } s.charAt(i) == 'B' s.charAt(i) s.charAt s i 'B' {
                if (index > 0)
                    index--;
            } if (index > 0)
                    index--; index > 0 index 0 index-- index {
                ans[index++] = s.charAt(i);
            } ans[index++] = s.charAt(i) ans[index++] ans index++ index s.charAt(i) s.charAt s i for (int i = 0; i < index; i++) {
            System.out.print(ans[i]);
        } int i = 0; int i = 0; i 0 i < index i index i++ i++ i {
            System.out.print(ans[i]);
        } {
            System.out.print(ans[i]);
        } System.out.print(ans[i]) System.out.print System.out System System.out ans[i] ans i String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String s = sc.next();
        char[] ans = new char[s.length()];

        int index = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == 'B') {
                if (index > 0)
                    index--;
            } else {
                ans[index++] = s.charAt(i);
            }
        }

        for (int i = 0; i < index; i++) {
            System.out.print(ans[i]);
        }
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String s = sc.next();
        char[] ans = new char[s.length()];

        int index = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == 'B') {
                if (index > 0)
                    index--;
            } else {
                ans[index++] = s.charAt(i);
            }
        }

        for (int i = 0; i < index; i++) {
            System.out.print(ans[i]);
        }
    }
} Main
import java.util.Scanner;

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

        String s = sc.next();
        char[] ans = new char[s.length()];

        int index = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == 'B') {
                if (index > 0)
                    index--;
            } else {
                ans[index++] = s.charAt(i);
            }
        }

        for (int i = 0; i < index; i++) {
            System.out.print(ans[i]);
        }
    }
}
