import java.io.BufferedReader;
import java.io.IOException;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.nio.charset.StandardCharsets;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.File;
import java.util.*;

public class Main {

    public static StringBuilder output = new StringBuilder();

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.next().trim();
        Solver solver = new Solver();
        solver.solve(s);
        System.out.println(output.reverse());
    }

}

class Solver {
    public void solve(String s) {
        String ans = "";
        int count = 0;
        for (int i = s.length() - 1; i >= 0; i--) {
            if (s.charAt(i) == 'B') {
                count++;
            } else {
                if (count > 0) {
                    count--;
                    continue;
                } else {
                    ans = ans.concat(Character.toString(s.charAt(i)));
                }
            }
        }
        Main.output.append(ans);
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.FileWriter; FileWriter java.io import java.io.PrintWriter; PrintWriter java.io import java.nio.charset.StandardCharsets; StandardCharsets java.nio.charset import java.io.BufferedWriter; BufferedWriter java.io import java.io.FileReader; FileReader java.io import java.io.File; File java.io import java.util.*; util.* java public class Main {

    public static StringBuilder output = new StringBuilder();

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.next().trim();
        Solver solver = new Solver();
        solver.solve(s);
        System.out.println(output.reverse());
    }

} Main public static StringBuilder output = new StringBuilder(); output new StringBuilder() public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.next().trim();
        Solver solver = new Solver();
        solver.solve(s);
        System.out.println(output.reverse());
    } main {
        Scanner in = new Scanner(System.in);
        String s = in.next().trim();
        Solver solver = new Solver();
        solver.solve(s);
        System.out.println(output.reverse());
    } Scanner in = new Scanner(System.in); in new Scanner(System.in) String s = in.next().trim(); s in.next().trim() in.next().trim in.next() in.next in Solver solver = new Solver(); solver new Solver() solver.solve(s) solver.solve solver s System.out.println(output.reverse()) System.out.println System.out System System.out output.reverse() output.reverse output String[] args args class Solver {
    public void solve(String s) {
        String ans = "";
        int count = 0;
        for (int i = s.length() - 1; i >= 0; i--) {
            if (s.charAt(i) == 'B') {
                count++;
            } else {
                if (count > 0) {
                    count--;
                    continue;
                } else {
                    ans = ans.concat(Character.toString(s.charAt(i)));
                }
            }
        }
        Main.output.append(ans);
    }
} Solver public void solve(String s) {
        String ans = "";
        int count = 0;
        for (int i = s.length() - 1; i >= 0; i--) {
            if (s.charAt(i) == 'B') {
                count++;
            } else {
                if (count > 0) {
                    count--;
                    continue;
                } else {
                    ans = ans.concat(Character.toString(s.charAt(i)));
                }
            }
        }
        Main.output.append(ans);
    } solve {
        String ans = "";
        int count = 0;
        for (int i = s.length() - 1; i >= 0; i--) {
            if (s.charAt(i) == 'B') {
                count++;
            } else {
                if (count > 0) {
                    count--;
                    continue;
                } else {
                    ans = ans.concat(Character.toString(s.charAt(i)));
                }
            }
        }
        Main.output.append(ans);
    } String ans = ""; ans "" int count = 0; count 0 for (int i = s.length() - 1; i >= 0; i--) {
            if (s.charAt(i) == 'B') {
                count++;
            } else {
                if (count > 0) {
                    count--;
                    continue;
                } else {
                    ans = ans.concat(Character.toString(s.charAt(i)));
                }
            }
        } int i = s.length() - 1; int i = s.length() - 1; i s.length() - 1 s.length() s.length s 1 i >= 0 i 0 i-- i-- i {
            if (s.charAt(i) == 'B') {
                count++;
            } else {
                if (count > 0) {
                    count--;
                    continue;
                } else {
                    ans = ans.concat(Character.toString(s.charAt(i)));
                }
            }
        } {
            if (s.charAt(i) == 'B') {
                count++;
            } else {
                if (count > 0) {
                    count--;
                    continue;
                } else {
                    ans = ans.concat(Character.toString(s.charAt(i)));
                }
            }
        } if (s.charAt(i) == 'B') {
                count++;
            } else {
                if (count > 0) {
                    count--;
                    continue;
                } else {
                    ans = ans.concat(Character.toString(s.charAt(i)));
                }
            } s.charAt(i) == 'B' s.charAt(i) s.charAt s i 'B' {
                count++;
            } count++ count {
                if (count > 0) {
                    count--;
                    continue;
                } else {
                    ans = ans.concat(Character.toString(s.charAt(i)));
                }
            } if (count > 0) {
                    count--;
                    continue;
                } else {
                    ans = ans.concat(Character.toString(s.charAt(i)));
                } count > 0 count 0 {
                    count--;
                    continue;
                } count-- count continue; {
                    ans = ans.concat(Character.toString(s.charAt(i)));
                } ans = ans.concat(Character.toString(s.charAt(i))) ans ans.concat(Character.toString(s.charAt(i))) ans.concat ans Character.toString(s.charAt(i)) Character.toString Character s.charAt(i) s.charAt s i Main.output.append(ans) Main.output.append Main.output Main Main.output ans String s s public class Main {

    public static StringBuilder output = new StringBuilder();

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.next().trim();
        Solver solver = new Solver();
        solver.solve(s);
        System.out.println(output.reverse());
    }

} public class Main {

    public static StringBuilder output = new StringBuilder();

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.next().trim();
        Solver solver = new Solver();
        solver.solve(s);
        System.out.println(output.reverse());
    }

} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.nio.charset.StandardCharsets;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.File;
import java.util.*;

public class Main {

    public static StringBuilder output = new StringBuilder();

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.next().trim();
        Solver solver = new Solver();
        solver.solve(s);
        System.out.println(output.reverse());
    }

}

class Solver {
    public void solve(String s) {
        String ans = "";
        int count = 0;
        for (int i = s.length() - 1; i >= 0; i--) {
            if (s.charAt(i) == 'B') {
                count++;
            } else {
                if (count > 0) {
                    count--;
                    continue;
                } else {
                    ans = ans.concat(Character.toString(s.charAt(i)));
                }
            }
        }
        Main.output.append(ans);
    }
}