#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ld = long double;

int cnt1[26], cnt2[26];
int res;

void solve(string s){
    int n = s.size();
    for(int i=0; i<26; i++) cnt1[i] = cnt2[i] = 0;
    int mid = n/2 - 1;
    while(s[mid] == s[n-mid-1]) mid--;
    for(int i=n-mid-1; i<n; i++) cnt2[s[i] - 'a']++;
    for(int i=0; i<=mid; i++) cnt1[s[i] - 'a']++;
    bool moze = 1;
    for(int i=0; i<26; i++){
        if(cnt1[i] != cnt2[i]) moze = 0;
    }
    if(moze){
        res = min(res, mid + 1);
        return;
    }
    for(int i=(n+1)/2; i<n; i++){
        cnt2[s[i] - 'a']--;
        if(i != n-i-1) cnt1[s[i] - 'a']++;
        moze = 1;
        for(int j=0; j<26; j++) if(cnt1[j] < cnt2[j]) moze = 0;
        if(moze){
            res = min(res, i + 1);
            return;
        }
    }
}

int main(){
    ios_base::sync_with_stdio(false), cin.tie(0);
    cout.precision(10);
    cout << fixed;

    string s;
    cin >> s;
    int n = s.size();
    for(int i=0; i<n; i++){
        if(s[i] != s[n-i-1]){
            s = s.substr(i, n-i-1 - i + 1);
            break;
        }
        if(i == n-1){
            cout << "1\n";
            return 0;
        }
    }
    res = s.size();
    solve(s);
    reverse(s.begin(), s.end());
    solve(s);
    cout << res << "\n";
    return 0;
}