import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char s[] = sc.next().toCharArray();
        sc.close();
        Deque<Integer> q = new ArrayDeque<>();
        for (char x : s) {
            if (q.isEmpty()) {
                if (x != 'B') {
                    q.add(x - 48);
                }
            } else if (x == 'B') {
                q.pollLast();
            } else {
                q.add(x - 48);
            }
        }
        for (int i : q) {
            System.out.print(i);
        }
        System.out.println();
    }
} import java.util.*; util.* java class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char s[] = sc.next().toCharArray();
        sc.close();
        Deque<Integer> q = new ArrayDeque<>();
        for (char x : s) {
            if (q.isEmpty()) {
                if (x != 'B') {
                    q.add(x - 48);
                }
            } else if (x == 'B') {
                q.pollLast();
            } else {
                q.add(x - 48);
            }
        }
        for (int i : q) {
            System.out.print(i);
        }
        System.out.println();
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char s[] = sc.next().toCharArray();
        sc.close();
        Deque<Integer> q = new ArrayDeque<>();
        for (char x : s) {
            if (q.isEmpty()) {
                if (x != 'B') {
                    q.add(x - 48);
                }
            } else if (x == 'B') {
                q.pollLast();
            } else {
                q.add(x - 48);
            }
        }
        for (int i : q) {
            System.out.print(i);
        }
        System.out.println();
    } main {
        Scanner sc = new Scanner(System.in);
        char s[] = sc.next().toCharArray();
        sc.close();
        Deque<Integer> q = new ArrayDeque<>();
        for (char x : s) {
            if (q.isEmpty()) {
                if (x != 'B') {
                    q.add(x - 48);
                }
            } else if (x == 'B') {
                q.pollLast();
            } else {
                q.add(x - 48);
            }
        }
        for (int i : q) {
            System.out.print(i);
        }
        System.out.println();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) char s[] = sc.next().toCharArray(); s sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc sc.close() sc.close sc Deque<Integer> q = new ArrayDeque<>(); q new ArrayDeque<>() for (char x : s) {
            if (q.isEmpty()) {
                if (x != 'B') {
                    q.add(x - 48);
                }
            } else if (x == 'B') {
                q.pollLast();
            } else {
                q.add(x - 48);
            }
        } char x s {
            if (q.isEmpty()) {
                if (x != 'B') {
                    q.add(x - 48);
                }
            } else if (x == 'B') {
                q.pollLast();
            } else {
                q.add(x - 48);
            }
        } {
            if (q.isEmpty()) {
                if (x != 'B') {
                    q.add(x - 48);
                }
            } else if (x == 'B') {
                q.pollLast();
            } else {
                q.add(x - 48);
            }
        } if (q.isEmpty()) {
                if (x != 'B') {
                    q.add(x - 48);
                }
            } else if (x == 'B') {
                q.pollLast();
            } else {
                q.add(x - 48);
            } q.isEmpty() q.isEmpty q {
                if (x != 'B') {
                    q.add(x - 48);
                }
            } if (x != 'B') {
                    q.add(x - 48);
                } x != 'B' x 'B' {
                    q.add(x - 48);
                } q.add(x - 48) q.add q x - 48 x 48 if (x == 'B') {
                q.pollLast();
            } else {
                q.add(x - 48);
            } x == 'B' x 'B' {
                q.pollLast();
            } q.pollLast() q.pollLast q {
                q.add(x - 48);
            } q.add(x - 48) q.add q x - 48 x 48 for (int i : q) {
            System.out.print(i);
        } int i q {
            System.out.print(i);
        } {
            System.out.print(i);
        } System.out.print(i) System.out.print System.out System System.out i System.out.println() System.out.println System.out System System.out String[] args args
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char s[] = sc.next().toCharArray();
        sc.close();
        Deque<Integer> q = new ArrayDeque<>();
        for (char x : s) {
            if (q.isEmpty()) {
                if (x != 'B') {
                    q.add(x - 48);
                }
            } else if (x == 'B') {
                q.pollLast();
            } else {
                q.add(x - 48);
            }
        }
        for (int i : q) {
            System.out.print(i);
        }
        System.out.println();
    }
}