import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String line = scan.nextLine();

        List<String> list = new ArrayList<>();

        for (int i=0; i < line.length(); i++) {
            char ch = line.charAt(i);

            if (ch == 'B') {
                if (list.size() != 0) list.remove(list.size() - 1);
            } else {
                list.add(String.valueOf(ch));
            }
        }

        System.out.println(String.join("", list));
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String line = scan.nextLine();

        List<String> list = new ArrayList<>();

        for (int i=0; i < line.length(); i++) {
            char ch = line.charAt(i);

            if (ch == 'B') {
                if (list.size() != 0) list.remove(list.size() - 1);
            } else {
                list.add(String.valueOf(ch));
            }
        }

        System.out.println(String.join("", list));
    }
} Main public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String line = scan.nextLine();

        List<String> list = new ArrayList<>();

        for (int i=0; i < line.length(); i++) {
            char ch = line.charAt(i);

            if (ch == 'B') {
                if (list.size() != 0) list.remove(list.size() - 1);
            } else {
                list.add(String.valueOf(ch));
            }
        }

        System.out.println(String.join("", list));
    } main {
        Scanner scan = new Scanner(System.in);
        String line = scan.nextLine();

        List<String> list = new ArrayList<>();

        for (int i=0; i < line.length(); i++) {
            char ch = line.charAt(i);

            if (ch == 'B') {
                if (list.size() != 0) list.remove(list.size() - 1);
            } else {
                list.add(String.valueOf(ch));
            }
        }

        System.out.println(String.join("", list));
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String line = scan.nextLine(); line scan.nextLine() scan.nextLine scan List<String> list = new ArrayList<>(); list new ArrayList<>() for (int i=0; i < line.length(); i++) {
            char ch = line.charAt(i);

            if (ch == 'B') {
                if (list.size() != 0) list.remove(list.size() - 1);
            } else {
                list.add(String.valueOf(ch));
            }
        } int i=0; int i=0; i 0 i < line.length() i line.length() line.length line i++ i++ i {
            char ch = line.charAt(i);

            if (ch == 'B') {
                if (list.size() != 0) list.remove(list.size() - 1);
            } else {
                list.add(String.valueOf(ch));
            }
        } {
            char ch = line.charAt(i);

            if (ch == 'B') {
                if (list.size() != 0) list.remove(list.size() - 1);
            } else {
                list.add(String.valueOf(ch));
            }
        } char ch = line.charAt(i); ch line.charAt(i) line.charAt line i if (ch == 'B') {
                if (list.size() != 0) list.remove(list.size() - 1);
            } else {
                list.add(String.valueOf(ch));
            } ch == 'B' ch 'B' {
                if (list.size() != 0) list.remove(list.size() - 1);
            } if (list.size() != 0) list.remove(list.size() - 1); list.size() != 0 list.size() list.size list 0 list.remove(list.size() - 1) list.remove list list.size() - 1 list.size() list.size list 1 {
                list.add(String.valueOf(ch));
            } list.add(String.valueOf(ch)) list.add list String.valueOf(ch) String.valueOf String ch System.out.println(String.join("", list)) System.out.println System.out System System.out String.join("", list) String.join String "" list String[] args args public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String line = scan.nextLine();

        List<String> list = new ArrayList<>();

        for (int i=0; i < line.length(); i++) {
            char ch = line.charAt(i);

            if (ch == 'B') {
                if (list.size() != 0) list.remove(list.size() - 1);
            } else {
                list.add(String.valueOf(ch));
            }
        }

        System.out.println(String.join("", list));
    }
} public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String line = scan.nextLine();

        List<String> list = new ArrayList<>();

        for (int i=0; i < line.length(); i++) {
            char ch = line.charAt(i);

            if (ch == 'B') {
                if (list.size() != 0) list.remove(list.size() - 1);
            } else {
                list.add(String.valueOf(ch));
            }
        }

        System.out.println(String.join("", list));
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String line = scan.nextLine();

        List<String> list = new ArrayList<>();

        for (int i=0; i < line.length(); i++) {
            char ch = line.charAt(i);

            if (ch == 'B') {
                if (list.size() != 0) list.remove(list.size() - 1);
            } else {
                list.add(String.valueOf(ch));
            }
        }

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