import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        String[] s = sc.next().split("");

        List<String> result = new ArrayList<>();
        for (String key : s) {
            if ("B".equals(key)) {
                if (!result.isEmpty()) {
                    result.remove(result.size() - 1);
                }
            } else {
                result.add(key);
            }
        }

        System.out.println(String.join("", result));
    }
} import java.util.ArrayList; ArrayList java.util import java.util.List; List java.util import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        String[] s = sc.next().split("");

        List<String> result = new ArrayList<>();
        for (String key : s) {
            if ("B".equals(key)) {
                if (!result.isEmpty()) {
                    result.remove(result.size() - 1);
                }
            } else {
                result.add(key);
            }
        }

        System.out.println(String.join("", result));
    }
} Main public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        String[] s = sc.next().split("");

        List<String> result = new ArrayList<>();
        for (String key : s) {
            if ("B".equals(key)) {
                if (!result.isEmpty()) {
                    result.remove(result.size() - 1);
                }
            } else {
                result.add(key);
            }
        }

        System.out.println(String.join("", result));
    } main {

        Scanner sc = new Scanner(System.in);
        String[] s = sc.next().split("");

        List<String> result = new ArrayList<>();
        for (String key : s) {
            if ("B".equals(key)) {
                if (!result.isEmpty()) {
                    result.remove(result.size() - 1);
                }
            } else {
                result.add(key);
            }
        }

        System.out.println(String.join("", result));
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String[] s = sc.next().split(""); s sc.next().split("") sc.next().split sc.next() sc.next sc "" List<String> result = new ArrayList<>(); result new ArrayList<>() for (String key : s) {
            if ("B".equals(key)) {
                if (!result.isEmpty()) {
                    result.remove(result.size() - 1);
                }
            } else {
                result.add(key);
            }
        } String key s {
            if ("B".equals(key)) {
                if (!result.isEmpty()) {
                    result.remove(result.size() - 1);
                }
            } else {
                result.add(key);
            }
        } {
            if ("B".equals(key)) {
                if (!result.isEmpty()) {
                    result.remove(result.size() - 1);
                }
            } else {
                result.add(key);
            }
        } if ("B".equals(key)) {
                if (!result.isEmpty()) {
                    result.remove(result.size() - 1);
                }
            } else {
                result.add(key);
            } "B".equals(key) "B".equals "B" key {
                if (!result.isEmpty()) {
                    result.remove(result.size() - 1);
                }
            } if (!result.isEmpty()) {
                    result.remove(result.size() - 1);
                } !result.isEmpty() result.isEmpty() result.isEmpty result {
                    result.remove(result.size() - 1);
                } result.remove(result.size() - 1) result.remove result result.size() - 1 result.size() result.size result 1 {
                result.add(key);
            } result.add(key) result.add result key System.out.println(String.join("", result)) System.out.println System.out System System.out String.join("", result) String.join String "" result String args[] args public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        String[] s = sc.next().split("");

        List<String> result = new ArrayList<>();
        for (String key : s) {
            if ("B".equals(key)) {
                if (!result.isEmpty()) {
                    result.remove(result.size() - 1);
                }
            } else {
                result.add(key);
            }
        }

        System.out.println(String.join("", result));
    }
} public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        String[] s = sc.next().split("");

        List<String> result = new ArrayList<>();
        for (String key : s) {
            if ("B".equals(key)) {
                if (!result.isEmpty()) {
                    result.remove(result.size() - 1);
                }
            } else {
                result.add(key);
            }
        }

        System.out.println(String.join("", result));
    }
} Main
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        String[] s = sc.next().split("");

        List<String> result = new ArrayList<>();
        for (String key : s) {
            if ("B".equals(key)) {
                if (!result.isEmpty()) {
                    result.remove(result.size() - 1);
                }
            } else {
                result.add(key);
            }
        }

        System.out.println(String.join("", result));
    }
}
