import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;

public class Main {

    public static void main(String[] args) throws Exception {
	    String input = Io.read();

        ArrayDeque<Character> q = new ArrayDeque<Character>();
	    for (char c : input.toCharArray()){
            if (c == 'B') {
                if (!q.isEmpty()){
                    q.removeLast();
                }
            } else {
                q.add(c);
            }
        }
        StringBuilder builder = new StringBuilder();
        for (char c : q.toArray(new Character[0])) {
	        builder.append(c);
        }

        Io.write(builder.toString());
    }
}

class Io {

    /**
     * 標準入力から1行ずつ受け取る
     * @return
     * @throws IOException
     */
    public static String read() throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();

        br.close();
        return line;
    }

    /**
     * 標準出力
     * @param line
     */
    public static void write(String line)
    {
        System.out.println(line);
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.ArrayDeque; ArrayDeque java.util public class Main {

    public static void main(String[] args) throws Exception {
	    String input = Io.read();

        ArrayDeque<Character> q = new ArrayDeque<Character>();
	    for (char c : input.toCharArray()){
            if (c == 'B') {
                if (!q.isEmpty()){
                    q.removeLast();
                }
            } else {
                q.add(c);
            }
        }
        StringBuilder builder = new StringBuilder();
        for (char c : q.toArray(new Character[0])) {
	        builder.append(c);
        }

        Io.write(builder.toString());
    }
} Main public static void main(String[] args) throws Exception {
	    String input = Io.read();

        ArrayDeque<Character> q = new ArrayDeque<Character>();
	    for (char c : input.toCharArray()){
            if (c == 'B') {
                if (!q.isEmpty()){
                    q.removeLast();
                }
            } else {
                q.add(c);
            }
        }
        StringBuilder builder = new StringBuilder();
        for (char c : q.toArray(new Character[0])) {
	        builder.append(c);
        }

        Io.write(builder.toString());
    } main {
	    String input = Io.read();

        ArrayDeque<Character> q = new ArrayDeque<Character>();
	    for (char c : input.toCharArray()){
            if (c == 'B') {
                if (!q.isEmpty()){
                    q.removeLast();
                }
            } else {
                q.add(c);
            }
        }
        StringBuilder builder = new StringBuilder();
        for (char c : q.toArray(new Character[0])) {
	        builder.append(c);
        }

        Io.write(builder.toString());
    } String input = Io.read(); input Io.read() Io.read Io ArrayDeque<Character> q = new ArrayDeque<Character>(); q new ArrayDeque<Character>() for (char c : input.toCharArray()){
            if (c == 'B') {
                if (!q.isEmpty()){
                    q.removeLast();
                }
            } else {
                q.add(c);
            }
        } char c input.toCharArray() input.toCharArray input {
            if (c == 'B') {
                if (!q.isEmpty()){
                    q.removeLast();
                }
            } else {
                q.add(c);
            }
        } {
            if (c == 'B') {
                if (!q.isEmpty()){
                    q.removeLast();
                }
            } else {
                q.add(c);
            }
        } if (c == 'B') {
                if (!q.isEmpty()){
                    q.removeLast();
                }
            } else {
                q.add(c);
            } c == 'B' c 'B' {
                if (!q.isEmpty()){
                    q.removeLast();
                }
            } if (!q.isEmpty()){
                    q.removeLast();
                } !q.isEmpty() q.isEmpty() q.isEmpty q {
                    q.removeLast();
                } q.removeLast() q.removeLast q {
                q.add(c);
            } q.add(c) q.add q c StringBuilder builder = new StringBuilder(); builder new StringBuilder() for (char c : q.toArray(new Character[0])) {
	        builder.append(c);
        } char c q.toArray(new Character[0]) q.toArray q new Character[0] 0 {
	        builder.append(c);
        } {
	        builder.append(c);
        } builder.append(c) builder.append builder c Io.write(builder.toString()) Io.write Io builder.toString() builder.toString builder String[] args args class Io {

    /**
     * 標準入力から1行ずつ受け取る
     * @return
     * @throws IOException
     */
    public static String read() throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();

        br.close();
        return line;
    }

    /**
     * 標準出力
     * @param line
     */
    public static void write(String line)
    {
        System.out.println(line);
    }
} Io /**
     * 標準入力から1行ずつ受け取る
     * @return
     * @throws IOException
     */
    public static String read() throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();

        br.close();
        return line;
    } read {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();

        br.close();
        return line;
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String line = br.readLine(); line br.readLine() br.readLine br br.close() br.close br return line; line /**
     * 標準出力
     * @param line
     */
    public static void write(String line)
    {
        System.out.println(line);
    } write {
        System.out.println(line);
    } System.out.println(line) System.out.println System.out System System.out line String line line public class Main {

    public static void main(String[] args) throws Exception {
	    String input = Io.read();

        ArrayDeque<Character> q = new ArrayDeque<Character>();
	    for (char c : input.toCharArray()){
            if (c == 'B') {
                if (!q.isEmpty()){
                    q.removeLast();
                }
            } else {
                q.add(c);
            }
        }
        StringBuilder builder = new StringBuilder();
        for (char c : q.toArray(new Character[0])) {
	        builder.append(c);
        }

        Io.write(builder.toString());
    }
} public class Main {

    public static void main(String[] args) throws Exception {
	    String input = Io.read();

        ArrayDeque<Character> q = new ArrayDeque<Character>();
	    for (char c : input.toCharArray()){
            if (c == 'B') {
                if (!q.isEmpty()){
                    q.removeLast();
                }
            } else {
                q.add(c);
            }
        }
        StringBuilder builder = new StringBuilder();
        for (char c : q.toArray(new Character[0])) {
	        builder.append(c);
        }

        Io.write(builder.toString());
    }
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;

public class Main {

    public static void main(String[] args) throws Exception {
	    String input = Io.read();

        ArrayDeque<Character> q = new ArrayDeque<Character>();
	    for (char c : input.toCharArray()){
            if (c == 'B') {
                if (!q.isEmpty()){
                    q.removeLast();
                }
            } else {
                q.add(c);
            }
        }
        StringBuilder builder = new StringBuilder();
        for (char c : q.toArray(new Character[0])) {
	        builder.append(c);
        }

        Io.write(builder.toString());
    }
}

class Io {

    /**
     * 標準入力から1行ずつ受け取る
     * @return
     * @throws IOException
     */
    public static String read() throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();

        br.close();
        return line;
    }

    /**
     * 標準出力
     * @param line
     */
    public static void write(String line)
    {
        System.out.println(line);
    }
}