#include<iostream>
using namespace std;
int main()
{
    string str;
    while(cin>>str)
    {
        int i=0;
        int len=str.size();
        int maxlen=0;
        while(str[i]!='\0')
        {
            int l=0;
            if(i>0)
            {
                l=i-1;
            }
            int r=i+1;
            if(r<len&&str[i]==str[r])//single
            {
                int temp=2;
                r=r+1;
                while(l>=0&&r<len&&str[l]==str[r])
                {
                    l--;
                    r++;
                    temp+=2;
                }
                if(temp>maxlen)maxlen=temp;
            }
            if(i>0)
            {
                l=i-1;
            }
            r=i+1;
            if(r<len&&str[l]==str[r])//double
            {
                int temp=3;
                l--;
                r++;
                while(l>=0&&r<len&&str[l]==str[r])
                {
                    l--;
                    r++;
                    temp+=2;
                }
                if(temp>maxlen)maxlen=temp;
            }
            i++;
        }
        cout<<maxlen<<endl;
    }
    return 0;
}