#include <bits/stdc++.h>
#define en '\n'
#define ll long long
#define sp " "

using namespace std;

int main()
{
    string T;
    cin >> T;
    int n = T.length();
    vector <int> cnt (26,0);
    int ans1 = n;
    int ans2 = n;
    int i1 = 0;
    int i2 = n - 1;
    while (i1 <= i2 && T[i1] == T[i2])
        i1++, i2--, ans1 -= 2, ans2 -= 2;
    for (int i = i1; i <= i2; i++)
    {
        int c = (int)T[i] - 97;
        cnt[c]++;
    }
    bool moze = true;
    for (int i = i1; i < n / 2; i++)
    {
        int c = (int)T[i] - 97;
        cnt[c] -= 2;
        if (cnt[c] >= 0)
            ans1--;
        else
        {
            moze = false;
            break;
        }
    }
    if (n % 2 == 0 && moze)
    {
        int j1 = n / 2;
        int j2 = j1 - 1;
        while (j1 < n && j2 >= 0 && T[j1] == T[j2])
            j1++, j2--, ans1--;
    }
    else if (moze)
    {
        int j1 = n / 2;
        int j2 = j1;
        while (j1 < n && j2 >= 0 && T[j1] == T[j2])
            j1++, j2--, ans1--;
    }
    for (int i = 0; i < 26; i++)
        cnt[i] = 0;
    for (int i = i1; i <= i2; i++)
    {
        int c = (int)T[i] - 97;
        cnt[c]++;
    }
    moze = true;
    for (int i = i2; i >= n / 2; i--)
    {
        int c = (int)T[i] - 97;
        cnt[c] -= 2;
        if (cnt[c] >= 0)
            ans2--;
        else
        {
            moze = false;
            break;
        }
    }
    if (n % 2 == 0 && moze)
    {
        int j2 = n / 2;
        int j1 = j2 - 1;
        while (j2 < n && j1 >= 0 && T[j1] == T[j2])
            j2++, j1--, ans2--;
    }
    else if (moze)
    {
        int j2 = n / 2;
        int j1 = j2;
        while (j2 < n && j1 >= 0 && T[j1] == T[j2])
            j2++, j1--, ans2--;
    }
    cout << min(max(1,ans1),max(1,ans2));
}