import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        ArrayDeque<Character> dq = new ArrayDeque<>();
        for(int i =0; S.length() > i; i++){
            char c = S.charAt(i);
            if(c == 'B' && dq.isEmpty() == false){
                dq.removeFirst();
            }else if(c == 'B' && dq.isEmpty()){
            }else{
                dq.addFirst(c);
            }
        }
        while(dq.isEmpty() == false){
            System.out.print(dq.removeLast());
        }

    }

} import java.util.*; util.* java public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        ArrayDeque<Character> dq = new ArrayDeque<>();
        for(int i =0; S.length() > i; i++){
            char c = S.charAt(i);
            if(c == 'B' && dq.isEmpty() == false){
                dq.removeFirst();
            }else if(c == 'B' && dq.isEmpty()){
            }else{
                dq.addFirst(c);
            }
        }
        while(dq.isEmpty() == false){
            System.out.print(dq.removeLast());
        }

    }

} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        ArrayDeque<Character> dq = new ArrayDeque<>();
        for(int i =0; S.length() > i; i++){
            char c = S.charAt(i);
            if(c == 'B' && dq.isEmpty() == false){
                dq.removeFirst();
            }else if(c == 'B' && dq.isEmpty()){
            }else{
                dq.addFirst(c);
            }
        }
        while(dq.isEmpty() == false){
            System.out.print(dq.removeLast());
        }

    } main {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        ArrayDeque<Character> dq = new ArrayDeque<>();
        for(int i =0; S.length() > i; i++){
            char c = S.charAt(i);
            if(c == 'B' && dq.isEmpty() == false){
                dq.removeFirst();
            }else if(c == 'B' && dq.isEmpty()){
            }else{
                dq.addFirst(c);
            }
        }
        while(dq.isEmpty() == false){
            System.out.print(dq.removeLast());
        }

    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String S = sc.next(); S sc.next() sc.next sc ArrayDeque<Character> dq = new ArrayDeque<>(); dq new ArrayDeque<>() for(int i =0; S.length() > i; i++){
            char c = S.charAt(i);
            if(c == 'B' && dq.isEmpty() == false){
                dq.removeFirst();
            }else if(c == 'B' && dq.isEmpty()){
            }else{
                dq.addFirst(c);
            }
        } int i =0; int i =0; i 0 S.length() > i S.length() S.length S i i++ i++ i {
            char c = S.charAt(i);
            if(c == 'B' && dq.isEmpty() == false){
                dq.removeFirst();
            }else if(c == 'B' && dq.isEmpty()){
            }else{
                dq.addFirst(c);
            }
        } {
            char c = S.charAt(i);
            if(c == 'B' && dq.isEmpty() == false){
                dq.removeFirst();
            }else if(c == 'B' && dq.isEmpty()){
            }else{
                dq.addFirst(c);
            }
        } char c = S.charAt(i); c S.charAt(i) S.charAt S i if(c == 'B' && dq.isEmpty() == false){
                dq.removeFirst();
            }else if(c == 'B' && dq.isEmpty()){
            }else{
                dq.addFirst(c);
            } c == 'B' && dq.isEmpty() == false c == 'B' c 'B' dq.isEmpty() == false dq.isEmpty() dq.isEmpty dq false {
                dq.removeFirst();
            } dq.removeFirst() dq.removeFirst dq if(c == 'B' && dq.isEmpty()){
            }else{
                dq.addFirst(c);
            } c == 'B' && dq.isEmpty() c == 'B' c 'B' dq.isEmpty() dq.isEmpty dq {
            } {
                dq.addFirst(c);
            } dq.addFirst(c) dq.addFirst dq c while(dq.isEmpty() == false){
            System.out.print(dq.removeLast());
        } dq.isEmpty() == false dq.isEmpty() dq.isEmpty dq false {
            System.out.print(dq.removeLast());
        } System.out.print(dq.removeLast()) System.out.print System.out System System.out dq.removeLast() dq.removeLast dq String[] args args public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        ArrayDeque<Character> dq = new ArrayDeque<>();
        for(int i =0; S.length() > i; i++){
            char c = S.charAt(i);
            if(c == 'B' && dq.isEmpty() == false){
                dq.removeFirst();
            }else if(c == 'B' && dq.isEmpty()){
            }else{
                dq.addFirst(c);
            }
        }
        while(dq.isEmpty() == false){
            System.out.print(dq.removeLast());
        }

    }

} public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        ArrayDeque<Character> dq = new ArrayDeque<>();
        for(int i =0; S.length() > i; i++){
            char c = S.charAt(i);
            if(c == 'B' && dq.isEmpty() == false){
                dq.removeFirst();
            }else if(c == 'B' && dq.isEmpty()){
            }else{
                dq.addFirst(c);
            }
        }
        while(dq.isEmpty() == false){
            System.out.print(dq.removeLast());
        }

    }

} Main
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        ArrayDeque<Character> dq = new ArrayDeque<>();
        for(int i =0; S.length() > i; i++){
            char c = S.charAt(i);
            if(c == 'B' && dq.isEmpty() == false){
                dq.removeFirst();
            }else if(c == 'B' && dq.isEmpty()){
            }else{
                dq.addFirst(c);
            }
        }
        while(dq.isEmpty() == false){
            System.out.print(dq.removeLast());
        }

    }

}