#include <iostream>
#include <string>
using namespace std;

int main()
{
    string t;
    cin >> t;
    int s = 0;
    long long j = 0;
    long long n = t.length();
    long long br = n-1;
    for (long long i = 0; i < n/2; i++) {
        
            if (t.at(i) != t.at(br))
            {
                s++;
                j = i;
                break;
            }
            br--;
    } 
    n = n -j;
    bool da = true, ne = true;
    long long j1 = 0;
    long long r = n,r1=n;
    if (s == 0)
        cout << 1;
    else
    {
        for (long long i = j; i < n; i++)
        {
            if (j1 == 0) {
                for (long long k = i + 1; k < n; k++) {
                    if (t.at(i) == t.at(k))
                    {
                        r--;
                        da = false;
                        break;
                    }
                }
                if (r == n)
                    j1++;
            }
            else
                break;
       }
        if (da)
            r = r - j;
        j1 = 0;
        for (long long i = n-1; i >= j; i--)
        {
            if (j1 == 0){
                for (long long k = i - 1; k >= j; k--) {
                    if (t.at(i) == t.at(k))
                    {
                        ne = false;
                        r1--;
                        break;
                    }
                }
            if (r1 == n)
                j1++;
        }
            else
                break;
        }
        if (ne)
            r1 = r1 - j;
        if(r<=r1)
            cout << r << endl;
        else
            cout << r1;
        
            

    }
   
}