#include <bits/stdc++.h>
using namespace std;
long long br[30];
long long br_segm[30];
string str;
bool moguc_palindrom_shuffle()
{
    long long j;
    for(j = 0; j < 26; j++)
        if(br_segm[j] < br[j])
            return 0;
    return 1;
}
void resi_zadatak(long long &ans, long long A, long long B, long long N, long long x)
{
    long long i;
    for(i = A; i < B; i++) br[str[i] - 'a']++;
    if(x == 1) br[str[i] - 'a']++;
    for(i = N - B; i < N - A; i++) br[str[i] - 'a']++;
    for(i = A; i < B; i++)
    {
        br_segm[str[i] - 'a']++;
        br[str[i] - 'a']--;
        if(moguc_palindrom_shuffle())
        {
            ans = min(ans, i - A + 1);
            return;
        }
    }
    if(x == 1)
    {
        br_segm[str[i] - 'a']++; br[str[i] - 'a']--;
        if(moguc_palindrom_shuffle()){ans = min(ans, i - A + 1);return;}
    }
    for(i = N - B; i < N - A; i++)
    {
        br_segm[str[i] - 'a']++;
        br[str[i] - 'a']--;
        if(moguc_palindrom_shuffle())
        {
            ans = min(ans, i - A + 1);
            return;
        }
    }
}
int main()
{
    long long ans, n, i, A = 0, B, loscentar = 0;
    ios_base::sync_with_stdio(false);
    cin >> str;
    n = str.size();
    ans = 2*n;


    B = (n - 1)/2;
    while(str[B] == str[n - B - 1]) B--;
    B++;
    while(str[A] == str[n - A - 1]  && A < B) A++;
    if(A == B){cout << 1; return 0;}


    for(i = 0; i < n; i++) br[str[i]-'a']++;
    for(i = 0; i < 30; i++)
    {
        if(br[i] % 2 == 1) {B = (n - 1)/2; loscentar = 1;}
    }
    for(i = 0; i < 30; i++) br[i] = 0;


    resi_zadatak(ans, A, B, n, loscentar);
    for(i = 0; i < 30; i++) {br[i] = 0; br_segm[i] = 0;}
    for(i = 0; i <= (n - 1)/2; i++) swap(str[i], str[n - i - 1]);
    resi_zadatak(ans, A, B, n, loscentar);
    cout << ans;
    return 0;
}