import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
char[] chrs = scan.nextLine().toCharArray();
int len = chrs.length;
boolean[][] dp = new boolean[len][len];
int ans = 1;
for (int i = len - 1; i > -1; i--) {
for (int j = i; j < len; j++) {
if (i == j || (chrs[i] == chrs[j] && (j - i <= 2 || dp[i + 1][j - 1]))) {
dp[i][j] = true;
}
if (dp[i][j] && j - i + 1 >= ans) {
ans = j - i + 1;
}
}
}
System.out.println(ans);
}
}