#include <stdint.h>
#include <stdio.h>
#include <string.h>

// 以字符串s的index下标为中心,计算最长的对称长度
uint32_t maxLen(char* s, uint32_t index)
{
    uint32_t length = 0;
    uint32_t result = 0;
    uint32_t max1 = 0, max2 = 0;
    int l,r;

    length = strlen(s);
    if (index > length) {
        result = 0;
    } else {
        // 尝试以 s[index] 为中心,以 ABCBA 形式计算最长的对称长度
        max1 = 1;
        for (l=index-1,r=index+1; (l>=0)&&(r<length); --l,++r) {
            if (s[l] == s[r]) max1 += 2;
            else break;
        }

        // 尝试以 s[index] 与 s[index+1] 为中心,以 ABCCBA 形式计算最长的对称长度
        if (s[index] == s[index+1]) {
            max2 = 2;
            for (l=index-1,r=index+2; (l>=0)&&(r<length); --l,++r) {
                if (s[l] == s[r]) max2 += 2;
                else break;
            }
        }
  
        // 取两种形式中较大的
        result = max1>max2 ? max1 : max2;
    }

    return result;
}

int main() {
    char s[2501] = {};
    int length=0, result=0, i, temp;

    scanf("%s", s);
    length = strlen(s);
    for (i=0; i<length-result; ++i) {
        temp = maxLen(s, i);
        result = temp>result ? temp : result;
    }
    printf("%d", result);

    return 0;
}