#include <stdio.h>
#include <string.h>
void findLong(char* s, int* len)
{
int length = 0;
int i,j;
int tempLen = 0;
*len = 0;
length = strlen(s);
for (i=0; i<length; ++i) { //按照 abcba 形式找
tempLen = 1;
for (j=1; i-j>=0&&i+j<length; ++j) {
if (s[i-j] == s[i+j]) tempLen+=2;
else break;
}
if (tempLen > *len) {
*len = tempLen;
} else {}
}
for (i=0; i<length-1; ++i) {//按照 abccba 形式找
if (s[i]==s[i+1]) {
tempLen = 2;
for (j=1; i-j>=0&&i+j+1<length; ++j) {
if (s[i-j] == s[i+j+1]) tempLen+=2;
else break;
}
if (tempLen > *len) {
*len = tempLen;
} else {}
} else {}
}
}
int main() {
char s[351] = {};
int length = 0;
int len;
while (scanf("%s", s) != EOF) {
findLong(s, &len);
printf("%d", len);
}
return 0;
}