#include <math.h>
#include <stdio.h>
#include <string.h>
int main() {
char input[2501];
while (scanf("%s", input) != EOF) {
int count = 0;
int len = strlen(input);
for(int i = 0; i < len; i++) {
for(int j = i + 1; j < len; j++) {
int tempcount = 0;
int tempi = i;
int tempj = j;
while(tempi < tempj && tempj >= 0 && input[tempi] == input[tempj]) {
tempi++;
tempj--;
tempcount++;
if(tempi == tempj) {
tempcount = tempcount * 2 + 1;
count = fmax(tempcount, count);
} else if(tempi > tempj) {
tempcount *= 2;
count = fmax(tempcount, count);
}
}
}
}
printf("%d\n", count);
}
return 0;
}