#include <bits/stdc++.h>

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

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

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++)
    {
        diff[i] = 0;
    }


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

    bool allzero = true;
    for(int i = 0; i<26; i++)
        if(diff[i] != 0)
            allzero = false;

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

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

    for(int i = first; i < n - first; i++)
    {
        diff[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;
}