#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <algorithm>
#include <iomanip>

#define ll long long

using namespace::std;

void solve() {
    string s; cin >> s;
    int n = s.length();
    int l = 0, r = n - 1;
    while(l < r && s[l] == s[r]) l++, r--;
    if(l >= r) cout << 1 << endl;
    else{
        vector<int> brs(26, 0);
        for(int i=l;i<=r;i++) brs[s[i] - 'a']++;
        vector<int> pombr(26, 0);
        int pre = 0;
        for(int i=l;i<=r;i++){
            pombr[s[i] - 'a']++;
            if(pombr[s[i] - 'a'] > brs[s[i] - 'a'] / 2){
                if(i > n / 2 && s[i] == s[n-1-i]) pre++;
                else if(i == n / 2 && brs[s[i] - 'a'] % 2) pre++;
                else break;
            } else pre++;
        }
        pombr.assign(26, 0);
        int suf = 0;
        for(int i=r;i>=l;i--){
            pombr[s[i] - 'a']++;
            if(pombr[s[i] - 'a'] > brs[s[i] - 'a'] / 2){
                if(i < n / 2 && s[i] == s[n-1-i]) suf++;
                else if(i == n / 2 && brs[s[i] - 'a'] % 2) suf++;
                else break;
            } else suf++;
        }
        int msp = max(suf, pre);
        cout << r - l + 1 - msp << endl;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    solve();
    return 0;
}