import java.util.Scanner;
import java.util.Stack;
public class Main {
    public static void main(String[] args){
        Scanner sc  = new Scanner(System.in);
        String s = sc.next();
        Stack<Character> stack = new Stack<>();
        for(int i = 0;i<s.length();i++){
            if(!stack.isEmpty()&&s.charAt(i)==stack.peek()){
                stack.pop();
                continue;
            }
            stack.push(s.charAt(i));
        }
        if(stack.isEmpty()){
            System.out.print(0);
        }else{
            Stack<Character> stack2 = new Stack<>();
            while(!stack.isEmpty()){
                stack2.push(stack.pop());

            }
            while(!stack2.isEmpty()){
                System.out.print(stack2.pop());
            }
        }
    }
}

模仿评论区的写的