#include "stdio.h"
#include "stdlib.h"
int parse( char *, int *);
int main ( int argc, char ** argv ){
//Get String
char * str = (char *)malloc(sizeof(char));
int i = 0;
str[0] = getchar();
while (1) {
if (str[i]== EOF){
str[i] = '\0';
break;
}
i++;
str = (char *)realloc(str, (i+2)*sizeof(char));
str[i] = getchar();
}
int * index = (int *)malloc((i + 1) * sizeof(int));
int j = 0;
while(str[j]){
index[j] = 1;
j++;
}
index[j] = '\0';
//Parse String
while(parse(str, index)) continue;
//Print String
j = 0;
while(str[j]){
if (index[j]){
putchar(str[j]);
}
j++;
}
free(str);
free(index);
return 0;
}
int parse(char * str, int * index) {
int i = 0;
int j = 0;
while (str[i]) {
if (!index[i]) {
i++;
continue;
}
//First element of array
if (i == 0){
if (!index[i+1]) {
// + SIDE 0
int ii = 1;
while (index[i+ii] == 0){
if (str[i+ii] == '\0') break;
if (str[i] == str[i + ii]){
index[i] = 0;
j++;
break;
}
ii++;
}
if (str[i] == str[i+ii]){
index[i] = 0;
index[i+ii] = 0;
j++;
}
}
else {
// + SIDE 1
if (str[i] == str[i+1]){
index[i] = 0;
index[i+1] = 0;
j++;
}
}
i++;
continue;
}
if (!index[i+1] && !index[i-1]) {
//BOTH SIDES 0
//Check + side
int ii = 1;
while (index[i+ii] == 0){
if (str[i+ii] == '\0') break;
if (str[i] == str[i + ii]){
index[i] = 0;
j++;
break;
}
ii++;
}
if (str[i] == str[i+ii]){
index[i] = 0;
index[i+ii] = 0;
j++;
}
//Check - side
ii = 1;
while (index[i-ii] == 0){
if (ii == i){
break;
}
if (str[i] == str[i - ii]){
index[i] = 0;
j++;
break;
}
ii++;
}
if (str[i] == str[i-ii]){
index[i] = 0;
index[i-ii] = 0;
j++;
}
}
else if (!index[i+1]) {
// + SIDE 0
//Check - side
if (str[i] == str[i-1]){
index[i] = 0;
index[i-1] = 0;
j++;
}
//Check + side
else{
int ii = 1;
while (index[i+ii] == 0){
if (str[i+ii] == '\0') break;
if (str[i] == str[i + ii]){
index[i] = 0;
j++;
break;
}
ii++;
}
if (str[i] == str[i+ii]){
index[i] = 0;
index[i+ii] = 0;
j++;
}
}
}
else if (!index[i-1]) {
// - SIDE 0
//check + side
if (str[i] == str[i+1]){
index[i] = 0;
index[i+1] = 0;
j++;
}
//Check - side
else{
int ii = 1;
while (index[i-ii] == 0){
if (ii == i){
break;
}
if (str[i] == str[i - ii]){
index[i] = 0;
j++;
break;
}
ii++;
}
if (str[i] == str[i-ii]){
index[i] = 0;
index[i-ii] = 0;
j++;
}
}
}
else {
//BOTH SIDES 1
if (str[i] == str[i+1]) {
index[i] = 0;
index[i+1] = 0;
j++;
}
if (str[i] == str[i-1]) {
index[i] = 0;
index[i-1] = 0;
j++;
}
}
i++;
}
if (j > 0) return 1;
return 0;
}