#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define sp ' '
#define en '\n'
using namespace std;
const int N = 1e5 + 2;
const ll mod = 1e9 + 7;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    int n = s.size();
    int l = 0, r = n - 1;
    while (l < r) {
        if (s[l] != s[r]) break;
        l += 1;
        r -= 1;
    }
    if (l >= r) {
        cout << 1 << en;
        return 0;
    }
    string t;
    for (int i = l; i <= r; i++) t += s[i];
    n = t.size();
    vector<int> a(26), b(26);
    int ans = n - 1;
    l = 0, r = n - 1;
    while (l < r) {
        a[t[l] - 'a'] += 1;
        b[t[r] - 'a'] += 1;
        int ok = 1;
        for (int i = 0; i < 26; i++) {
            ok &= (a[i] == b[i]);
        }
        if (ok == 1) {
            ans = r - l;
            break;
        }
        l += 1;
        r -= 1;
    }
    cout << ans << en;
    return 0;

}