import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char[] c = s.toCharArray();
        char[] p = new char[s.length()];
        int x = 0;
        for(int i = 0;i < s.length();i++){
            if(c[i] == 'B'){
                x--;
                if(x < 0){
                    x = 0;
                }
                continue;
            }
            p[x] = c[i];
            x++;
        }
        for(int i = 0;i < x;i++){
            System.out.print(p[i]);
        }
        System.out.println();
    }
} 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[] c = s.toCharArray();
        char[] p = new char[s.length()];
        int x = 0;
        for(int i = 0;i < s.length();i++){
            if(c[i] == 'B'){
                x--;
                if(x < 0){
                    x = 0;
                }
                continue;
            }
            p[x] = c[i];
            x++;
        }
        for(int i = 0;i < x;i++){
            System.out.print(p[i]);
        }
        System.out.println();
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char[] c = s.toCharArray();
        char[] p = new char[s.length()];
        int x = 0;
        for(int i = 0;i < s.length();i++){
            if(c[i] == 'B'){
                x--;
                if(x < 0){
                    x = 0;
                }
                continue;
            }
            p[x] = c[i];
            x++;
        }
        for(int i = 0;i < x;i++){
            System.out.print(p[i]);
        }
        System.out.println();
    } main {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char[] c = s.toCharArray();
        char[] p = new char[s.length()];
        int x = 0;
        for(int i = 0;i < s.length();i++){
            if(c[i] == 'B'){
                x--;
                if(x < 0){
                    x = 0;
                }
                continue;
            }
            p[x] = c[i];
            x++;
        }
        for(int i = 0;i < x;i++){
            System.out.print(p[i]);
        }
        System.out.println();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc char[] c = s.toCharArray(); c s.toCharArray() s.toCharArray s char[] p = new char[s.length()]; p new char[s.length()] s.length() s.length s int x = 0; x 0 for(int i = 0;i < s.length();i++){
            if(c[i] == 'B'){
                x--;
                if(x < 0){
                    x = 0;
                }
                continue;
            }
            p[x] = c[i];
            x++;
        } int i = 0; int i = 0; i 0 i < s.length() i s.length() s.length s i++ i++ i {
            if(c[i] == 'B'){
                x--;
                if(x < 0){
                    x = 0;
                }
                continue;
            }
            p[x] = c[i];
            x++;
        } {
            if(c[i] == 'B'){
                x--;
                if(x < 0){
                    x = 0;
                }
                continue;
            }
            p[x] = c[i];
            x++;
        } if(c[i] == 'B'){
                x--;
                if(x < 0){
                    x = 0;
                }
                continue;
            } c[i] == 'B' c[i] c i 'B' {
                x--;
                if(x < 0){
                    x = 0;
                }
                continue;
            } x-- x if(x < 0){
                    x = 0;
                } x < 0 x 0 {
                    x = 0;
                } x = 0 x 0 continue; p[x] = c[i] p[x] p x c[i] c i x++ x for(int i = 0;i < x;i++){
            System.out.print(p[i]);
        } int i = 0; int i = 0; i 0 i < x i x i++ i++ i {
            System.out.print(p[i]);
        } {
            System.out.print(p[i]);
        } System.out.print(p[i]) System.out.print System.out System System.out p[i] p i System.out.println() System.out.println System.out System System.out String[] args args public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char[] c = s.toCharArray();
        char[] p = new char[s.length()];
        int x = 0;
        for(int i = 0;i < s.length();i++){
            if(c[i] == 'B'){
                x--;
                if(x < 0){
                    x = 0;
                }
                continue;
            }
            p[x] = c[i];
            x++;
        }
        for(int i = 0;i < x;i++){
            System.out.print(p[i]);
        }
        System.out.println();
    }
} public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char[] c = s.toCharArray();
        char[] p = new char[s.length()];
        int x = 0;
        for(int i = 0;i < s.length();i++){
            if(c[i] == 'B'){
                x--;
                if(x < 0){
                    x = 0;
                }
                continue;
            }
            p[x] = c[i];
            x++;
        }
        for(int i = 0;i < x;i++){
            System.out.print(p[i]);
        }
        System.out.println();
    }
} 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[] c = s.toCharArray();
        char[] p = new char[s.length()];
        int x = 0;
        for(int i = 0;i < s.length();i++){
            if(c[i] == 'B'){
                x--;
                if(x < 0){
                    x = 0;
                }
                continue;
            }
            p[x] = c[i];
            x++;
        }
        for(int i = 0;i < x;i++){
            System.out.print(p[i]);
        }
        System.out.println();
    }
}
