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

public class Main {
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in), 32768);
    static PrintWriter out = new PrintWriter(System.out);
    static StringTokenizer t;

    static String sn() {
        while (t == null || !t.hasMoreTokens()) {
            try {
                t = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                throw new RuntimeException();
            }
        }
        return t.nextToken();
    }

    static int ni() {
        return Integer.parseInt(sn());
    }

    static long nlo() {
        return Long.parseLong(sn());
    }

    public static void main(String args[]) {
        int t = 1;//ni();
        while (t-- > 0) {
            solve();
        }
        out.close();
    }

    static long mod = (long) 1e9 + 7;

    static long pro(long a, long b) {
        return (a % mod * b % mod) % mod;
    }

    static int maxn = 200005;

    static void solve() {
        char c[] = sn().toCharArray();
        int n = c.length;
        Stack<Character> st = new Stack<>();
        for (int i = 0; i < n; i++) {
            if (c[i] == 'B') {
                if (st.isEmpty()) continue;
                st.pop();
            } else
                st.push(c[i]);
        }
        StringBuilder sb = new StringBuilder();
        while (!st.isEmpty())
            sb.append(st.pop());
        out.println(sb.reverse());
    }
} import java.util.*; util.* java import java.io.*; io.* java public class Main {
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in), 32768);
    static PrintWriter out = new PrintWriter(System.out);
    static StringTokenizer t;

    static String sn() {
        while (t == null || !t.hasMoreTokens()) {
            try {
                t = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                throw new RuntimeException();
            }
        }
        return t.nextToken();
    }

    static int ni() {
        return Integer.parseInt(sn());
    }

    static long nlo() {
        return Long.parseLong(sn());
    }

    public static void main(String args[]) {
        int t = 1;//ni();
        while (t-- > 0) {
            solve();
        }
        out.close();
    }

    static long mod = (long) 1e9 + 7;

    static long pro(long a, long b) {
        return (a % mod * b % mod) % mod;
    }

    static int maxn = 200005;

    static void solve() {
        char c[] = sn().toCharArray();
        int n = c.length;
        Stack<Character> st = new Stack<>();
        for (int i = 0; i < n; i++) {
            if (c[i] == 'B') {
                if (st.isEmpty()) continue;
                st.pop();
            } else
                st.push(c[i]);
        }
        StringBuilder sb = new StringBuilder();
        while (!st.isEmpty())
            sb.append(st.pop());
        out.println(sb.reverse());
    }
} Main static BufferedReader br = new BufferedReader(new InputStreamReader(System.in), 32768); br new BufferedReader(new InputStreamReader(System.in), 32768) static PrintWriter out = new PrintWriter(System.out); out new PrintWriter(System.out) static StringTokenizer t; t static long mod = (long) 1e9 + 7; mod (long) 1e9 + 7 (long) 1e9 7 static int maxn = 200005; maxn 200005 static String sn() {
        while (t == null || !t.hasMoreTokens()) {
            try {
                t = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                throw new RuntimeException();
            }
        }
        return t.nextToken();
    } sn {
        while (t == null || !t.hasMoreTokens()) {
            try {
                t = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                throw new RuntimeException();
            }
        }
        return t.nextToken();
    } while (t == null || !t.hasMoreTokens()) {
            try {
                t = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                throw new RuntimeException();
            }
        } t == null || !t.hasMoreTokens() t == null t null !t.hasMoreTokens() t.hasMoreTokens() t.hasMoreTokens t {
            try {
                t = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                throw new RuntimeException();
            }
        } try {
                t = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                throw new RuntimeException();
            } catch (IOException e) {
                throw new RuntimeException();
            } IOException e {
                throw new RuntimeException();
            } throw new RuntimeException(); new RuntimeException() {
                t = new StringTokenizer(br.readLine());
            } t = new StringTokenizer(br.readLine()) t new StringTokenizer(br.readLine()) return t.nextToken(); t.nextToken() t.nextToken t static int ni() {
        return Integer.parseInt(sn());
    } ni {
        return Integer.parseInt(sn());
    } return Integer.parseInt(sn()); Integer.parseInt(sn()) Integer.parseInt Integer sn() sn static long nlo() {
        return Long.parseLong(sn());
    } nlo {
        return Long.parseLong(sn());
    } return Long.parseLong(sn()); Long.parseLong(sn()) Long.parseLong Long sn() sn public static void main(String args[]) {
        int t = 1;//ni();
        while (t-- > 0) {
            solve();
        }
        out.close();
    } main {
        int t = 1;//ni();
        while (t-- > 0) {
            solve();
        }
        out.close();
    } int t = 1; t 1 while (t-- > 0) {
            solve();
        } t-- > 0 t-- t 0 {
            solve();
        } solve() solve out.close() out.close out String args[] args static long pro(long a, long b) {
        return (a % mod * b % mod) % mod;
    } pro {
        return (a % mod * b % mod) % mod;
    } return (a % mod * b % mod) % mod; (a % mod * b % mod) % mod (a % mod * b % mod) a % mod * b a % mod a mod b mod mod long a a long b b static void solve() {
        char c[] = sn().toCharArray();
        int n = c.length;
        Stack<Character> st = new Stack<>();
        for (int i = 0; i < n; i++) {
            if (c[i] == 'B') {
                if (st.isEmpty()) continue;
                st.pop();
            } else
                st.push(c[i]);
        }
        StringBuilder sb = new StringBuilder();
        while (!st.isEmpty())
            sb.append(st.pop());
        out.println(sb.reverse());
    } solve {
        char c[] = sn().toCharArray();
        int n = c.length;
        Stack<Character> st = new Stack<>();
        for (int i = 0; i < n; i++) {
            if (c[i] == 'B') {
                if (st.isEmpty()) continue;
                st.pop();
            } else
                st.push(c[i]);
        }
        StringBuilder sb = new StringBuilder();
        while (!st.isEmpty())
            sb.append(st.pop());
        out.println(sb.reverse());
    } char c[] = sn().toCharArray(); c sn().toCharArray() sn().toCharArray sn() sn int n = c.length; n c.length c c.length Stack<Character> st = new Stack<>(); st new Stack<>() for (int i = 0; i < n; i++) {
            if (c[i] == 'B') {
                if (st.isEmpty()) continue;
                st.pop();
            } else
                st.push(c[i]);
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            if (c[i] == 'B') {
                if (st.isEmpty()) continue;
                st.pop();
            } else
                st.push(c[i]);
        } {
            if (c[i] == 'B') {
                if (st.isEmpty()) continue;
                st.pop();
            } else
                st.push(c[i]);
        } if (c[i] == 'B') {
                if (st.isEmpty()) continue;
                st.pop();
            } else
                st.push(c[i]); c[i] == 'B' c[i] c i 'B' {
                if (st.isEmpty()) continue;
                st.pop();
            } if (st.isEmpty()) continue; st.isEmpty() st.isEmpty st continue; st.pop() st.pop st st.push(c[i]) st.push st c[i] c i StringBuilder sb = new StringBuilder(); sb new StringBuilder() while (!st.isEmpty())
            sb.append(st.pop()); !st.isEmpty() st.isEmpty() st.isEmpty st sb.append(st.pop()) sb.append sb st.pop() st.pop st out.println(sb.reverse()) out.println out sb.reverse() sb.reverse sb public class Main {
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in), 32768);
    static PrintWriter out = new PrintWriter(System.out);
    static StringTokenizer t;

    static String sn() {
        while (t == null || !t.hasMoreTokens()) {
            try {
                t = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                throw new RuntimeException();
            }
        }
        return t.nextToken();
    }

    static int ni() {
        return Integer.parseInt(sn());
    }

    static long nlo() {
        return Long.parseLong(sn());
    }

    public static void main(String args[]) {
        int t = 1;//ni();
        while (t-- > 0) {
            solve();
        }
        out.close();
    }

    static long mod = (long) 1e9 + 7;

    static long pro(long a, long b) {
        return (a % mod * b % mod) % mod;
    }

    static int maxn = 200005;

    static void solve() {
        char c[] = sn().toCharArray();
        int n = c.length;
        Stack<Character> st = new Stack<>();
        for (int i = 0; i < n; i++) {
            if (c[i] == 'B') {
                if (st.isEmpty()) continue;
                st.pop();
            } else
                st.push(c[i]);
        }
        StringBuilder sb = new StringBuilder();
        while (!st.isEmpty())
            sb.append(st.pop());
        out.println(sb.reverse());
    }
} public class Main {
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in), 32768);
    static PrintWriter out = new PrintWriter(System.out);
    static StringTokenizer t;

    static String sn() {
        while (t == null || !t.hasMoreTokens()) {
            try {
                t = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                throw new RuntimeException();
            }
        }
        return t.nextToken();
    }

    static int ni() {
        return Integer.parseInt(sn());
    }

    static long nlo() {
        return Long.parseLong(sn());
    }

    public static void main(String args[]) {
        int t = 1;//ni();
        while (t-- > 0) {
            solve();
        }
        out.close();
    }

    static long mod = (long) 1e9 + 7;

    static long pro(long a, long b) {
        return (a % mod * b % mod) % mod;
    }

    static int maxn = 200005;

    static void solve() {
        char c[] = sn().toCharArray();
        int n = c.length;
        Stack<Character> st = new Stack<>();
        for (int i = 0; i < n; i++) {
            if (c[i] == 'B') {
                if (st.isEmpty()) continue;
                st.pop();
            } else
                st.push(c[i]);
        }
        StringBuilder sb = new StringBuilder();
        while (!st.isEmpty())
            sb.append(st.pop());
        out.println(sb.reverse());
    }
} Main
import java.util.*;
import java.io.*;

public class Main {
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in), 32768);
    static PrintWriter out = new PrintWriter(System.out);
    static StringTokenizer t;

    static String sn() {
        while (t == null || !t.hasMoreTokens()) {
            try {
                t = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                throw new RuntimeException();
            }
        }
        return t.nextToken();
    }

    static int ni() {
        return Integer.parseInt(sn());
    }

    static long nlo() {
        return Long.parseLong(sn());
    }

    public static void main(String args[]) {
        int t = 1;//ni();
        while (t-- > 0) {
            solve();
        }
        out.close();
    }

    static long mod = (long) 1e9 + 7;

    static long pro(long a, long b) {
        return (a % mod * b % mod) % mod;
    }

    static int maxn = 200005;

    static void solve() {
        char c[] = sn().toCharArray();
        int n = c.length;
        Stack<Character> st = new Stack<>();
        for (int i = 0; i < n; i++) {
            if (c[i] == 'B') {
                if (st.isEmpty()) continue;
                st.pop();
            } else
                st.push(c[i]);
        }
        StringBuilder sb = new StringBuilder();
        while (!st.isEmpty())
            sb.append(st.pop());
        out.println(sb.reverse());
    }
}