#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();
    vector<int> a(26), b(26);
    vector<int> ind;
    int l = 0, r = n - 1;
    while (l < r) {
        if (s[l] != s[r]) ind.push_back(l);
        a[s[l] - 'a'] += 1;
        b[s[r] - 'a'] += 1;
        l += 1;
        r -= 1;
    }
    if (ind.empty()) {
        cout << 1 << en;
        return 0;
    }
    int ok = 1;
    for (int i = 0; i < 26; i++) {
        ok &= (a[i] == b[i]);
    }
    if (ok == 1) cout << ind.back() - ind[0] + 1 << en;
    else cout << n - 2 * ind[0] - 1 << en;
    return 0;

}