#include <bits/stdc++.h>
#include <iostream>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> order_set;
//mt19937 mt_rand(chrono::high_resolution_clock::now().time_since_epoch().count());
//uniform_int_distribution<int> gen(-1e9, 1e8); ///(min, max)
//int random() {return gen(mt_rand);}
const int mxN = 3001;
const int mod = 1e9+7;
const int mxlogN = 20;
const int mxK = 26;
const ll inf = 1e9;

int cnt[mxK];
int cnt2[mxK];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    string s; cin >> s;
    int n = s.size();
    int l=0,r=n-1;
    while(l < r && s[l]==s[r]) l++, r--;
    if(l>=r)
    {
        cout << "1\n";
        return 0;
    }
    ///consider prefix or suffix
    int bad = 0;
    for(int i = l; i <= r; i++)
    {
        int k = s[i]-'a';
        if(!cnt[k]++) bad++;
    }
    int c=-1;
    for(int i = 0; i < mxK; i++) if(cnt[i]&1) c = i;
    bool skip = 0;
    if(n%2==1 && s[n/2]-'a'==c)
    {
        cnt[c]--;
        if(!cnt[c]) bad--;
        skip = 1;
    }
    int obad = bad;
    int ans = r-l+1;
    for(int i = l; i < r; i++)
    {
        if(skip && i==n/2) continue;
        int k = s[i]-'a';
        cnt2[k]++;
        cnt[k]--;
        if(cnt2[k] >= cnt[k] && cnt2[k]-cnt[k]<=1) bad--;
        if(!bad)
        {
            ans = min(ans, i-l+1);
            //cout << "moze prefix " << i-l+1 << "\n";
        }
    }
    for(int i = l; i < r; i++)
    {
        if(skip && i==n/2) continue;
        int k = s[i]-'a';
        cnt2[k]--;
        cnt[k]++;
    }
    bad = obad;
    for(int i = r; i > l; i--)
    {
        if(skip && i==n/2) continue;
        int k = s[i]-'a';
        cnt2[k]++;
        cnt[k]--;
        if(cnt2[k] >= cnt[k] && cnt2[k]-cnt[k]<=1) bad--;
        if(!bad)
        {
            ans = min(ans, r-i+1);
            //cout << "moze sufix " << r-i+1 << "\n";
        }
    }
    cout << ans << "\n";
}