
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		int p = 0; 
		char ans[];
		ans = new char[s.length()];		
		
		for(int i = 0; i < s.length(); ++i) {
			if(s.charAt(i) == 'B') {
				if(p != 0)--p;
				ans[p] = '\0';
			}
			else ans[p++] = s.charAt(i);
		}
		
		String ans1 = "";
		for(char c:ans) {
			if(c == '\0')break;
			ans1 += c;
		}
		
		System.out.println(ans1);
		sc.close();
	}

} 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();
		int p = 0; 
		char ans[];
		ans = new char[s.length()];		
		
		for(int i = 0; i < s.length(); ++i) {
			if(s.charAt(i) == 'B') {
				if(p != 0)--p;
				ans[p] = '\0';
			}
			else ans[p++] = s.charAt(i);
		}
		
		String ans1 = "";
		for(char c:ans) {
			if(c == '\0')break;
			ans1 += c;
		}
		
		System.out.println(ans1);
		sc.close();
	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		int p = 0; 
		char ans[];
		ans = new char[s.length()];		
		
		for(int i = 0; i < s.length(); ++i) {
			if(s.charAt(i) == 'B') {
				if(p != 0)--p;
				ans[p] = '\0';
			}
			else ans[p++] = s.charAt(i);
		}
		
		String ans1 = "";
		for(char c:ans) {
			if(c == '\0')break;
			ans1 += c;
		}
		
		System.out.println(ans1);
		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		int p = 0; 
		char ans[];
		ans = new char[s.length()];		
		
		for(int i = 0; i < s.length(); ++i) {
			if(s.charAt(i) == 'B') {
				if(p != 0)--p;
				ans[p] = '\0';
			}
			else ans[p++] = s.charAt(i);
		}
		
		String ans1 = "";
		for(char c:ans) {
			if(c == '\0')break;
			ans1 += c;
		}
		
		System.out.println(ans1);
		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc int p = 0; p 0 char ans[]; ans ans = new char[s.length()] ans new char[s.length()] s.length() s.length s for(int i = 0; i < s.length(); ++i) {
			if(s.charAt(i) == 'B') {
				if(p != 0)--p;
				ans[p] = '\0';
			}
			else ans[p++] = s.charAt(i);
		} int i = 0; int i = 0; i 0 i < s.length() i s.length() s.length s ++i ++i i {
			if(s.charAt(i) == 'B') {
				if(p != 0)--p;
				ans[p] = '\0';
			}
			else ans[p++] = s.charAt(i);
		} {
			if(s.charAt(i) == 'B') {
				if(p != 0)--p;
				ans[p] = '\0';
			}
			else ans[p++] = s.charAt(i);
		} if(s.charAt(i) == 'B') {
				if(p != 0)--p;
				ans[p] = '\0';
			}
			else ans[p++] = s.charAt(i); s.charAt(i) == 'B' s.charAt(i) s.charAt s i 'B' {
				if(p != 0)--p;
				ans[p] = '\0';
			} if(p != 0)--p; p != 0 p 0 --p p ans[p] = '\0' ans[p] ans p '\0' ans[p++] = s.charAt(i) ans[p++] ans p++ p s.charAt(i) s.charAt s i String ans1 = ""; ans1 "" for(char c:ans) {
			if(c == '\0')break;
			ans1 += c;
		} char c ans {
			if(c == '\0')break;
			ans1 += c;
		} {
			if(c == '\0')break;
			ans1 += c;
		} if(c == '\0')break; c == '\0' c '\0' break; ans1 += c ans1 c System.out.println(ans1) System.out.println System.out System System.out ans1 sc.close() sc.close sc String[] args args public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		int p = 0; 
		char ans[];
		ans = new char[s.length()];		
		
		for(int i = 0; i < s.length(); ++i) {
			if(s.charAt(i) == 'B') {
				if(p != 0)--p;
				ans[p] = '\0';
			}
			else ans[p++] = s.charAt(i);
		}
		
		String ans1 = "";
		for(char c:ans) {
			if(c == '\0')break;
			ans1 += c;
		}
		
		System.out.println(ans1);
		sc.close();
	}

} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		int p = 0; 
		char ans[];
		ans = new char[s.length()];		
		
		for(int i = 0; i < s.length(); ++i) {
			if(s.charAt(i) == 'B') {
				if(p != 0)--p;
				ans[p] = '\0';
			}
			else ans[p++] = s.charAt(i);
		}
		
		String ans1 = "";
		for(char c:ans) {
			if(c == '\0')break;
			ans1 += c;
		}
		
		System.out.println(ans1);
		sc.close();
	}

} Main

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		int p = 0; 
		char ans[];
		ans = new char[s.length()];		
		
		for(int i = 0; i < s.length(); ++i) {
			if(s.charAt(i) == 'B') {
				if(p != 0)--p;
				ans[p] = '\0';
			}
			else ans[p++] = s.charAt(i);
		}
		
		String ans1 = "";
		for(char c:ans) {
			if(c == '\0')break;
			ans1 += c;
		}
		
		System.out.println(ans1);
		sc.close();
	}

}
