# -*- coding:utf-8 -*-

class Palindrome:
    def getstr(self,A,n):
        re = []
        for i in range(n):
            for j in range(i + 1,n + 1):
                re.append(A[i:j])
        return re
    def choose(self,A,n):
        tmp = []
        for k in self.getstr(A,n):
            if k == k[::-1]:
                tmp.append(len(k))
        return tmp
    def getLongestPalindrome(self, A, n):
        # write code here
        res = self.choose(A, n)
        return max(res)