#include <bits/stdc++.h>

const unsigned int ORMASK = 1;
const unsigned int ANDMASK = UINT_MAX - 1;

int niz[200005];
int left[26];
int right[26];
int diff[26];

//int diffsum()
//{
//    int result = 0;
//    for(int i = 0; i < 26; i++)
//        result += left[i] - right[i];
//
//    return result;
//}

int diffsum()
{
    int result = 0;
    for(int i = 0; i < 26; i++)
        result += diff[i];

    return result;
}

int main()
{
    int n = 0;
    char ch;
    while ((ch = getchar()) != '\n' && ch != EOF)
    {
        niz[n] = ch - 'a';
        n++;
    }

    int first = -1;
    int last = -1;
    for(int i = 0; i < n/2; i++)
    {
        if(niz[i] != niz[n - 1 - i])
        {
            if(first == -1)
                first = i;

            last = i;
        }
    }

    if(first == -1)
    {
        printf("1");
        return 0;
    }

    for(int i = 0; i<26; i++)
    {
//        left[i] = 0;
//        right[i] = 0;

        diff[i] = 0;
    }

//    int diff = 0;
//    for(int i = first; i < n/2; i++)
//    {
//        left[niz[i]]++;
//        right[niz[n-1-i]]++;
//
//        if(left[niz[i]] == right[niz[i]])
//            diff = diff & (ANDMASK << niz[i]);
//        else
//            diff = diff | (ORMASK << niz[i]);
//
//        if(left[niz[n-1-i]] == right[niz[n-1-i]])
//            diff = diff & (ANDMASK << niz[n-1-i]);
//        else
//            diff = diff | (ORMASK << niz[n-1-i]);
//
//        if(i >= last && diff == 0)
//        {
//            printf("%d", i - first + 1);
//            return 0;
//        }
//    }
//
//    for(int i = first; i < n - first; i++)
//    {
//        right[niz[i]]++;
//    }

    for(int i = first; i <= last; i++)
    {
        diff[niz[i]]++;
        diff[niz[n-1-i]]--;
    }

    if(diffsum == 0)
    {
        printf("%d", last - first + 1);
        return 0;
    }

//    for(int i = last+1; i < n - first; i++)
//    {
//        if(i>n/2)
//        {
//
//        }
//        else
//        {
//            diff[niz[i]]++;
//            diff[niz[n-1-i]]--;
//        }
//    }

    for(int i = 0; i<26; i++)
        diff[i] = 0;

    for(int i = first; i < n - first; i++)
    {
        diff[niz[i]]--;
    }

//    for(int i = n/2; i < n - first; i++)
//    {
//        left[niz[i]]++;
//        right[niz[i]]--;
//
//        if(left[niz[i]] == right[niz[i]])
//            diff = diff & (ANDMASK << niz[i]);
//        else
//            diff = diff | (ORMASK << niz[i]);
//    }

    int minlen = 999999999;
    for(int i = first; i < n - first; i++)
    {
        diff[niz[i]] += 2;

        bool allpositive = true;
        bool allnegative = true;
        for(int j = 0; j<26; j++)
        {
            if(diff[j] > 0) allnegative = false;
            if(diff[j] < 0) allpositive = false;
        }

        if(allpositive && diffsum() / 2 <= i - n/2)
        {
            if(i - first < minlen)
                minlen = i - first;
        }

        if(allnegative && diffsum() / 2 >= i - n/2)
        {
            if(n - first - 2 - i < minlen)
                minlen = n - first - 2 - i;
        }

    }

    if(minlen == 999999999)
        minlen = n - 2 * first;

    printf("%d", minlen + 1);

    return 0;
}