#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main()
{
char str[300010] = "";
scanf("%s", str);
int i = 0;
int top = 0;
char *stack = (char *)malloc(sizeof(char) * strlen(str));
for (i = 0; (top >= 0) && (i < strlen(str)); i++)
{
if (top == 0)
{
stack[top] = str[i];
top++;
}
else if (top > 0)
{
if (stack[top - 1] == str[i])
{
top--;
stack[top] = '\0';
}
else
{
stack[top] = str[i];
top++;
}
}
}
if (strlen(stack) == 0)
{
printf("0\n");
}
else
{
printf("%s\n", stack);
}
return 0;
}

京公网安备 11010502036488号