import java.util.Scanner;
import java.util.TreeSet;

public class Main {
    public static void main(String[] args){
        new Main().run();
    }
    TreeSet<Integer> set;

    private void run() {
        Scanner scanner = new Scanner(System.in);
        String S = scanner.next();
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < S.length(); i++) {
            if(S.charAt(i) == 'B') {
                if(sb.length() > 0) sb.delete(sb.length()-1, sb.length());
            }else{
                sb.append(S.charAt(i));
            }
        }
        System.out.println(sb.toString());
    }

} import java.util.Scanner; Scanner java.util import java.util.TreeSet; TreeSet java.util public class Main {
    public static void main(String[] args){
        new Main().run();
    }
    TreeSet<Integer> set;

    private void run() {
        Scanner scanner = new Scanner(System.in);
        String S = scanner.next();
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < S.length(); i++) {
            if(S.charAt(i) == 'B') {
                if(sb.length() > 0) sb.delete(sb.length()-1, sb.length());
            }else{
                sb.append(S.charAt(i));
            }
        }
        System.out.println(sb.toString());
    }

} Main TreeSet<Integer> set; set public static void main(String[] args){
        new Main().run();
    } main {
        new Main().run();
    } new Main().run() new Main().run new Main() String[] args args private void run() {
        Scanner scanner = new Scanner(System.in);
        String S = scanner.next();
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < S.length(); i++) {
            if(S.charAt(i) == 'B') {
                if(sb.length() > 0) sb.delete(sb.length()-1, sb.length());
            }else{
                sb.append(S.charAt(i));
            }
        }
        System.out.println(sb.toString());
    } run {
        Scanner scanner = new Scanner(System.in);
        String S = scanner.next();
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < S.length(); i++) {
            if(S.charAt(i) == 'B') {
                if(sb.length() > 0) sb.delete(sb.length()-1, sb.length());
            }else{
                sb.append(S.charAt(i));
            }
        }
        System.out.println(sb.toString());
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) String S = scanner.next(); S scanner.next() scanner.next scanner StringBuilder sb = new StringBuilder(); sb new StringBuilder() for(int i = 0; i < S.length(); i++) {
            if(S.charAt(i) == 'B') {
                if(sb.length() > 0) sb.delete(sb.length()-1, sb.length());
            }else{
                sb.append(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(sb.length() > 0) sb.delete(sb.length()-1, sb.length());
            }else{
                sb.append(S.charAt(i));
            }
        } {
            if(S.charAt(i) == 'B') {
                if(sb.length() > 0) sb.delete(sb.length()-1, sb.length());
            }else{
                sb.append(S.charAt(i));
            }
        } if(S.charAt(i) == 'B') {
                if(sb.length() > 0) sb.delete(sb.length()-1, sb.length());
            }else{
                sb.append(S.charAt(i));
            } S.charAt(i) == 'B' S.charAt(i) S.charAt S i 'B' {
                if(sb.length() > 0) sb.delete(sb.length()-1, sb.length());
            } if(sb.length() > 0) sb.delete(sb.length()-1, sb.length()); sb.length() > 0 sb.length() sb.length sb 0 sb.delete(sb.length()-1, sb.length()) sb.delete sb sb.length()-1 sb.length() sb.length sb 1 sb.length() sb.length sb {
                sb.append(S.charAt(i));
            } sb.append(S.charAt(i)) sb.append sb S.charAt(i) S.charAt S i System.out.println(sb.toString()) System.out.println System.out System System.out sb.toString() sb.toString sb public class Main {
    public static void main(String[] args){
        new Main().run();
    }
    TreeSet<Integer> set;

    private void run() {
        Scanner scanner = new Scanner(System.in);
        String S = scanner.next();
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < S.length(); i++) {
            if(S.charAt(i) == 'B') {
                if(sb.length() > 0) sb.delete(sb.length()-1, sb.length());
            }else{
                sb.append(S.charAt(i));
            }
        }
        System.out.println(sb.toString());
    }

} public class Main {
    public static void main(String[] args){
        new Main().run();
    }
    TreeSet<Integer> set;

    private void run() {
        Scanner scanner = new Scanner(System.in);
        String S = scanner.next();
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < S.length(); i++) {
            if(S.charAt(i) == 'B') {
                if(sb.length() > 0) sb.delete(sb.length()-1, sb.length());
            }else{
                sb.append(S.charAt(i));
            }
        }
        System.out.println(sb.toString());
    }

} Main
import java.util.Scanner;
import java.util.TreeSet;

public class Main {
    public static void main(String[] args){
        new Main().run();
    }
    TreeSet<Integer> set;

    private void run() {
        Scanner scanner = new Scanner(System.in);
        String S = scanner.next();
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < S.length(); i++) {
            if(S.charAt(i) == 'B') {
                if(sb.length() > 0) sb.delete(sb.length()-1, sb.length());
            }else{
                sb.append(S.charAt(i));
            }
        }
        System.out.println(sb.toString());
    }

}