import java.util.*;


public class Solution {
    /**
     * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
     *
     * 
     * @param A string字符串 
     * @return int整型
     */
    public int maxLen(char[] arr, int left, int right) {
        while(left > -1 && right < arr.length && arr[left] == arr[right]) {
            left--;
            right++;
        }
        return right - left - 1;
    }
    public int getLongestPalindrome (String A) {
        // write code here
        char[] arr = A.toCharArray();
        int N = arr.length;
        if(N == 1) {
            return 1;
        } else if(N == 2) {
            if(arr[0] == arr[1]) {
                return 2;
            }
            return 1;
        }
        int maxLen = 1;
        for(int i = 1; i < N - 1; i++) {
            int len1 = maxLen(arr, i, i + 1);
            int len2 = maxLen(arr, i, i);
            maxLen = Math.max(Math.max(len1, len2), maxLen);
        }
        return maxLen;
    }
}