import java.util.*;


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