while True:
    try:
        #获取输入数据
        data1 = input()
        #当有效密码串的中心为一个字符时
        n1 = 0
        N1 = []
        for k in range(0,len(data1)):
            try:
                while data1[k-n1] == data1[k+n1] and k >= n1:
                    n1 = n1 + 1
                else:
                    N1.append(n1)
                    n1 = 0
            except:
                N1.append(n1)
                n1 = 0
        #当有效密码串中心为一个字符时,有效密码串的最大长度
        L1 = (max(N1)-1 )*2+1
        
        #当有效密码串中心为两个字符时
        n2 = 0
        N2 = []
        for k in range(0,len(data1)):
            try:
                while k >= n2 and data1[k] == data1[k+1] and data1[k-n2] == data1[k+1+n2]:
                    n2 = n2 + 1
                else:
                    N2.append(n2)
                    n2 = 0
            except:
                N2.append(n2)
                n2 = 0
        #当有效密码串中心有两个字符时,有效密码串的最大长度
        L2 = 2*max(N2)
        #对于全局而言,找出L1和L2中较大的值即为结果
        print(max(L1,L2))
    except:
        break