#include <bits/stdc++.h>

using namespace std;

int racuanje(string t)
{
    int odg = 0, odg1;
    string slova;
    int brP;
    //od napred
    for (int i = 0; i < t.length(); i++)
    {
        slova += t[i];
        brP = count(slova.begin(), slova.end(), slova[i]);
        if (brP > 1)
        {
            odg = slova.length() - 1;
            break;
        }
    }
    for (int i = t.length(); i > 0; i--)
    {
        slova += t[i];
        brP = count(slova.begin(), slova.end(), slova[i]);
        if (brP > 1)
        {
            odg1 = slova.length() - 1;
            break;
        }
    }
    return t.length() - min(odg, odg1);
}

int palindrom(string t, char *p, char *k)
{
    int br = 0;
    while (p < k)
    {
        if (*p != *k)
        {
            br++;
            break;
        }
        else
        {
            p++;
            k--;
            t.erase(t.size() - 1);
            t.erase(0, 1);
        }
        if (p >= k)
            return 1;
    }
    return racuanje(t);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cerr.tie(0);
    cout.tie(0);
    char t[200000];
    cin >> t;
    char *p = t, *k;
    int duzina = strlen(t);
    k = t + duzina - 1;
    cout << palindrom(t, p, k) << endl;

    return 0;
}