import java.util.* ; public class Main { public static void main(String... args) { Scanner scan = new Scanner(System.in) ; while(scan.hasNextLine()) { String str = scan.nextLine() ; System.out.println(fun(str)) ; } } //返回消除后的最简字符串 public static String fun(String str) { char[] arr = str.toCharArray() ; Stack<Character> st = new Stack<>() ;//利用栈结构 for(int i = 0 ; i < arr.length ; i ++) { char cur = arr[i] ; if(st.isEmpty() || st.peek() != cur) { st.push(cur) ; } else { st.pop() ;//消除 } } StringBuilder sb = new StringBuilder() ; while(!st.isEmpty()) { sb.append(st.pop()) ; } sb.reverse() ; String ret = sb.toString() ; return ret.equals("") ? "0" : ret; } }