#include <vector>
#include <string>
#include <iostream>
using namespace std;
void solve1(){
// O(n^2)的时间复杂度,会超时
// solve2() 利用栈进行操作,有O(n)的时间复杂度
// 先储存字符串
// 依次遍历字符串,如果需要清除,先记录,后消除
// 重复上一步,直至在某一循环中没有清除
// 如果没有清除,则说明已经符合条件,退出循环并输出字符串
string s;
cin >> s;
vector<int> v;
v.reserve(300000);
bool need_replace = true;
while (need_replace) {
need_replace = false;
int n = s.size();
int i=0;
while(i < n-1){
if(s[i]==s[i+1]){
need_replace = true;
v.push_back(i);
i += 1;
}
i += 1;
}
int m=v.size();
while (m--) {
int index = *(v.rbegin());
s.replace(index,2,"");
v.pop_back();
}
}
cout << s;
}
void solve2(){
// 读取单个字符c
// 如果栈为空,将字符c压入栈
// 如果栈不为空,检查栈顶字符是否与元素c相等
// 如果相等,则将栈顶元素弹出,且不储存字符c
// 如果不相等,则将字符c压入栈
vector<char> v;
v.reserve(300000);
char c;
while(cin >> c){
if(v.size()==0){
v.push_back(c);
}else {
if(c == *(v.rbegin())){
v.pop_back();
}else {
v.push_back(c);
}
}
}
if(v.size() != 0){
for(char c_:v){
cout << c_;
}
}else {
cout << 0;
}
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
std::cout.tie(nullptr);
solve2();
}
// 64 位输出请用 printf("%lld")