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

#define ll long long
const ll N = 200001;
const ll inf = 1e9 + 7;
char c[N];
int br[N][26];
bool pali = true;

bool check (int l, int n) {
    int tr[26], tr2[26];
    if (l + 1 <= n - l) {
        if (c[l] != c[n - l - 1])
            pali = false;
    }
    if (!pali)
        return false;
    for (int i = 0; i < 26; i++) {
        tr[i] = br[l][i];
        tr2[i] = br[n][i] - br[n - l][i];
    }
    if (l <= n / 2) {
        for (int i = 0; i < 26; i++) {
            if (tr[i] != tr2[i])
                return false;
        }
        return true;
    }
    for (int i = 0; i < 26; i++) {
        tr[i] -= (br[n][i] - br[l][i]);
        if (tr[i] < 0)
            return false;
    }
    return true;
}

bool check1 (int l, int n) {
    int tr[26], tr2[26];
    if (l + 1 <= n - l) {
        if (c[l] != c[n - l - 1])
            pali = false;
    }
    if (!pali)
        return false;
    for (int i = 0; i < 26; i++) {
        tr2[i] = br[l][i];
        tr[i] = br[n][i] - br[n - l][i];
    }
    if (l <= n / 2) {
        for (int i = 0; i < 26; i++) {
            if (tr[i] != tr2[i])
                return false;
        }
        return true;
    }
    for (int i = 0; i < 26; i++) {
        tr[i] -= br[n - l][i];
        if (tr[i] < 0)
            return false;
    }
    return true;
}

void solve() {
    string s;
    int n;
    cin >> s;
    n = s.size();
    for (int i = 0; i < n; i++) {
        c[i] = s[i];
    }
    int ind = 0;
    while (c[ind] == c[n - 1 - ind] && ind < n - 1 - ind) {
        ind++;
    }
    for (int i = ind; i < n - ind; i++) {
        c[i - ind] = c[i];
    }
    n -= 2 * ind;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 26; j++)
            br[i + 1][j] = br[i][j];
        br[i + 1][c[i] - 'a']++;
    }
    int minimum = n;
    for (int l = n; l > 0; l--) {
        if(check(l, n))
            minimum = min(minimum, l);
    }
    pali = true;
    for (int l = n; l > 0; l--) {
        if (check1(l, n))
            minimum = min(minimum, l);
    }
    cout << minimum << endl;
}

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