#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
#define fb(i,a,b) for(int (i) = (a); (i) >= (b); --(i))
#define mod 998244353
#define xx first
#define yy second
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define ll long long
#define pii pair<int,int>


using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;/// find_by_order(x)(x+1th) , order_of_key() (strictly less)
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());


string x;
int n;
int poj[26];

bool pal(int l, int r){
    ff(i,l,r){
        if(x[i] != x[n-1-i])return 0;
    }
    return 1;
}

bool radi(int l, int r){
    if(n-r-1>r){
        if(!pal(r+1,n-1-r-1))return 0;
        ff(i,0,25)poj[i] = 0;
        ff(i,l,r)poj[x[i]-'a']++;
        ff(i,n-r-1,n-l-1)poj[x[i]-'a']--;
        ff(i,0,25){
            if(poj[i] !=0)return 0;
        }
        return 1;
    }
    ff(i,0,25)poj[i] = 0;
    ff(i,l,r)poj[x[i]-'a']++;
    ff(i,r+1,n-l-1)poj[x[i]-'a']--;
    ff(i,0,25){
        if(poj[i]<0)return 0;
    }
    return 1;
}

int main()
{

    ios_base::sync_with_stdio(false); cin.tie(0);

    cin >> x;
    n = x.length();
    int idx = -1;
    ff(i,0,n - 1){
        if(x[i] != x[n-1-i]){idx = i; break;}
    }
    if(idx == -1){
        cout << 1 << "\n";
        return 0;
    }
    int l = idx + 1;
    int r = n-1;
    int ans = 0;
    while(l < r){
        int mid = (l + r) / 2;
        if(radi(idx,mid))r = mid;
        else l = mid + 1;
    }
    ans = l-idx+1;
    reverse(x.begin(), x.end());
     l = idx + 1;
     r = n-1;
   // int ans = 0;
    while(l < r){
        int mid = (l + r) / 2;
        if(radi(idx,mid))r = mid;
        else l = mid + 1;
    }
    ans = min(ans, l-idx+1);
    cout << ans << "\n";
    return 0;
}