#include <bits/stdc++.h>

#define pb push_back

using namespace std;

int main() {

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

    string s;
    cin >> s;
    int n = s.size();
    
    vector<int> lettersL[26], lettersR[26], letters[26];
    for(int i = 0; i < n; i++) {
        letters[s[i] - 'a'].pb(i);
        if(i < n / 2)
            lettersL[s[i] - 'a'].pb(i);
        else if(n % 2 == 0 || i != n / 2)
            lettersR[s[i] - 'a'].pb(i);
    }
    
    char c = '#';
    for(int i = 0; i < 26; i++) {
        if(letters[i].size() % 2) {
            c = i + 'a';
            break;
        }
    }

    int left = n, right = -1;
    if(n % 2 && c != s[n / 2])
        left = right = n / 2;
    
    for(int l = 0; l < 26; l++) {
        int target = letters[l].size() / 2;
        int Lsize = lettersL[l].size(), Rsize = lettersR[l].size();
        if(target < Rsize)
            right = max(right, lettersR[l][Rsize - target - 1]);
        else if(target < Lsize)
            left = min(left, lettersL[l][target]);
    }

    for(int i = 0; i < n / 2; i++) {
        int j = n - i - 1;
        if(i >= left || j <= right)
            break;
        if(s[i] != s[j]) {
            if(left - i < j - right)
                left = i;
            else
                right = j;
            break;
        }
    }

    if(left > right) {
        cout << 1 << endl;
        return 0;
    }
    cout << right - left + 1 << endl;
    return 0;
}