import java.util.Scanner;
public class DuiChengStringLength {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String str = "qhbrivaighqmgafhthxicdiixpefhwwefdebwczswqqdjxulhuhceqrxechddtlbbltddhcexrqechuhluxjdqqwszcwenakceymkxfqpqxctbsousrwwhooxjtcqnvb";
// String str = sc.nextLine();
System.out.println(duiChengStringLength(str));
}
private static int duiChengStringLength(String str) {
int maxLength = 0;
for (int i = 0; i < str.length(); i++) {
char c = str.charAt(i);
int from = i;
while (str.indexOf(c, from + 1) != -1) {
int to = str.indexOf(c, from + 1);
int length = to - i + 1;
if (isDuiCheng(str.substring(i, to + 1))) {
maxLength = Math.max(maxLength, length);
}
from = to;
}
}
return maxLength;
}
private static boolean isDuiCheng(String str) {
boolean result = true;
int length = str.length();
int half = length / 2;
for (int i = 0; i < half; i++) {
if (str.charAt(i) != str.charAt(length - 1 - i)) {
result = false;
break;
}
}
return result;
}
}