import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        char[] s = scanner.next().toCharArray();
        List<String> list = new ArrayList<>();
        for (int i = s.length - 1, c = 0; i >= 0; i--) {
            if (s[i] == 'B') {
                c++;
            } else if (0 < c) {
                c--;
            } else {
                list.add(0, String.valueOf(s[i]));
            }
        }
        System.out.println(String.join("", list));
    }
} import java.util.*; util.* java public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        char[] s = scanner.next().toCharArray();
        List<String> list = new ArrayList<>();
        for (int i = s.length - 1, c = 0; i >= 0; i--) {
            if (s[i] == 'B') {
                c++;
            } else if (0 < c) {
                c--;
            } else {
                list.add(0, String.valueOf(s[i]));
            }
        }
        System.out.println(String.join("", list));
    }
} Main static Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) public static void main(String[]$) {
        char[] s = scanner.next().toCharArray();
        List<String> list = new ArrayList<>();
        for (int i = s.length - 1, c = 0; i >= 0; i--) {
            if (s[i] == 'B') {
                c++;
            } else if (0 < c) {
                c--;
            } else {
                list.add(0, String.valueOf(s[i]));
            }
        }
        System.out.println(String.join("", list));
    } main {
        char[] s = scanner.next().toCharArray();
        List<String> list = new ArrayList<>();
        for (int i = s.length - 1, c = 0; i >= 0; i--) {
            if (s[i] == 'B') {
                c++;
            } else if (0 < c) {
                c--;
            } else {
                list.add(0, String.valueOf(s[i]));
            }
        }
        System.out.println(String.join("", list));
    } char[] s = scanner.next().toCharArray(); s scanner.next().toCharArray() scanner.next().toCharArray scanner.next() scanner.next scanner List<String> list = new ArrayList<>(); list new ArrayList<>() for (int i = s.length - 1, c = 0; i >= 0; i--) {
            if (s[i] == 'B') {
                c++;
            } else if (0 < c) {
                c--;
            } else {
                list.add(0, String.valueOf(s[i]));
            }
        } int i = s.length - 1, c = 0; int i = s.length - 1 i s.length - 1 s.length s s.length 1 c = 0; c 0 i >= 0 i 0 i-- i-- i {
            if (s[i] == 'B') {
                c++;
            } else if (0 < c) {
                c--;
            } else {
                list.add(0, String.valueOf(s[i]));
            }
        } {
            if (s[i] == 'B') {
                c++;
            } else if (0 < c) {
                c--;
            } else {
                list.add(0, String.valueOf(s[i]));
            }
        } if (s[i] == 'B') {
                c++;
            } else if (0 < c) {
                c--;
            } else {
                list.add(0, String.valueOf(s[i]));
            } s[i] == 'B' s[i] s i 'B' {
                c++;
            } c++ c if (0 < c) {
                c--;
            } else {
                list.add(0, String.valueOf(s[i]));
            } 0 < c 0 c {
                c--;
            } c-- c {
                list.add(0, String.valueOf(s[i]));
            } list.add(0, String.valueOf(s[i])) list.add list 0 String.valueOf(s[i]) String.valueOf String s[i] s i System.out.println(String.join("", list)) System.out.println System.out System System.out String.join("", list) String.join String "" list String[]$ $ public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        char[] s = scanner.next().toCharArray();
        List<String> list = new ArrayList<>();
        for (int i = s.length - 1, c = 0; i >= 0; i--) {
            if (s[i] == 'B') {
                c++;
            } else if (0 < c) {
                c--;
            } else {
                list.add(0, String.valueOf(s[i]));
            }
        }
        System.out.println(String.join("", list));
    }
} public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        char[] s = scanner.next().toCharArray();
        List<String> list = new ArrayList<>();
        for (int i = s.length - 1, c = 0; i >= 0; i--) {
            if (s[i] == 'B') {
                c++;
            } else if (0 < c) {
                c--;
            } else {
                list.add(0, String.valueOf(s[i]));
            }
        }
        System.out.println(String.join("", list));
    }
} Main
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        char[] s = scanner.next().toCharArray();
        List<String> list = new ArrayList<>();
        for (int i = s.length - 1, c = 0; i >= 0; i--) {
            if (s[i] == 'B') {
                c++;
            } else if (0 < c) {
                c--;
            } else {
                list.add(0, String.valueOf(s[i]));
            }
        }
        System.out.println(String.join("", list));
    }
}