//https://atcoder.jp/contests/abc043/tasks/abc043_b

import java.io.*;
import java.util.ArrayList;

class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String S = br.readLine();
        ArrayList<String> s = new ArrayList<>();
        for (int i=0;i<S.length();i++){
            if (String.valueOf(S.charAt(i)).equals("B")){
                if (s.size()!=0){
                    s.remove(s.size()-1);
                } else {
                    s.clear();
                }
            } else {
                s.add(String.valueOf(S.charAt(i)));
            }
        }
        String ans = String.join("", s);
        System.out.println(ans);
    }
} import java.io.*; io.* java import java.util.ArrayList; ArrayList java.util class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String S = br.readLine();
        ArrayList<String> s = new ArrayList<>();
        for (int i=0;i<S.length();i++){
            if (String.valueOf(S.charAt(i)).equals("B")){
                if (s.size()!=0){
                    s.remove(s.size()-1);
                } else {
                    s.clear();
                }
            } else {
                s.add(String.valueOf(S.charAt(i)));
            }
        }
        String ans = String.join("", s);
        System.out.println(ans);
    }
} Main public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String S = br.readLine();
        ArrayList<String> s = new ArrayList<>();
        for (int i=0;i<S.length();i++){
            if (String.valueOf(S.charAt(i)).equals("B")){
                if (s.size()!=0){
                    s.remove(s.size()-1);
                } else {
                    s.clear();
                }
            } else {
                s.add(String.valueOf(S.charAt(i)));
            }
        }
        String ans = String.join("", s);
        System.out.println(ans);
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String S = br.readLine();
        ArrayList<String> s = new ArrayList<>();
        for (int i=0;i<S.length();i++){
            if (String.valueOf(S.charAt(i)).equals("B")){
                if (s.size()!=0){
                    s.remove(s.size()-1);
                } else {
                    s.clear();
                }
            } else {
                s.add(String.valueOf(S.charAt(i)));
            }
        }
        String ans = String.join("", s);
        System.out.println(ans);
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String S = br.readLine(); S br.readLine() br.readLine br ArrayList<String> s = new ArrayList<>(); s new ArrayList<>() for (int i=0;i<S.length();i++){
            if (String.valueOf(S.charAt(i)).equals("B")){
                if (s.size()!=0){
                    s.remove(s.size()-1);
                } else {
                    s.clear();
                }
            } else {
                s.add(String.valueOf(S.charAt(i)));
            }
        } int i=0; int i=0; i 0 i<S.length() i S.length() S.length S i++ i++ i {
            if (String.valueOf(S.charAt(i)).equals("B")){
                if (s.size()!=0){
                    s.remove(s.size()-1);
                } else {
                    s.clear();
                }
            } else {
                s.add(String.valueOf(S.charAt(i)));
            }
        } {
            if (String.valueOf(S.charAt(i)).equals("B")){
                if (s.size()!=0){
                    s.remove(s.size()-1);
                } else {
                    s.clear();
                }
            } else {
                s.add(String.valueOf(S.charAt(i)));
            }
        } if (String.valueOf(S.charAt(i)).equals("B")){
                if (s.size()!=0){
                    s.remove(s.size()-1);
                } else {
                    s.clear();
                }
            } else {
                s.add(String.valueOf(S.charAt(i)));
            } String.valueOf(S.charAt(i)).equals("B") String.valueOf(S.charAt(i)).equals String.valueOf(S.charAt(i)) String.valueOf String S.charAt(i) S.charAt S i "B" {
                if (s.size()!=0){
                    s.remove(s.size()-1);
                } else {
                    s.clear();
                }
            } if (s.size()!=0){
                    s.remove(s.size()-1);
                } else {
                    s.clear();
                } s.size()!=0 s.size() s.size s 0 {
                    s.remove(s.size()-1);
                } s.remove(s.size()-1) s.remove s s.size()-1 s.size() s.size s 1 {
                    s.clear();
                } s.clear() s.clear s {
                s.add(String.valueOf(S.charAt(i)));
            } s.add(String.valueOf(S.charAt(i))) s.add s String.valueOf(S.charAt(i)) String.valueOf String S.charAt(i) S.charAt S i String ans = String.join("", s); ans String.join("", s) String.join String "" s System.out.println(ans) System.out.println System.out System System.out ans String[] args args
//https://atcoder.jp/contests/abc043/tasks/abc043_b

import java.io.*;
import java.util.ArrayList;

class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String S = br.readLine();
        ArrayList<String> s = new ArrayList<>();
        for (int i=0;i<S.length();i++){
            if (String.valueOf(S.charAt(i)).equals("B")){
                if (s.size()!=0){
                    s.remove(s.size()-1);
                } else {
                    s.clear();
                }
            } else {
                s.add(String.valueOf(S.charAt(i)));
            }
        }
        String ans = String.join("", s);
        System.out.println(ans);
    }
}