#include <iostream>
#include <unordered_map>
using namespace std;
bool funcija(unordered_map<char, int> x) {
    for (auto i : x) if (i.second > 0) return false;
    return true;
}
int main() {
    cin.tie(NULL);
    ios::sync_with_stdio(false);
    string a;
    cin >> a;
    bool b = true;
    int c = a.length(), d, e;
    unordered_map<char, int> f, g;
    if (c & 1) {
        unordered_map<char, int> h;
        char k;
        for (int i = 0; i < c; i++) h[a[i]]++;
        for (auto i : h)
            if (i.second & 1) k = i.first;
        for (int i = 0; i < c / 2; i++) {
            if (a[i] != a[c - i - 1]) {
                d = i;
                e = c - i - 1;
                f[a[e]]++;
                g[a[d]]++;
                break;
            }
        }
        if (a[c / 2] != k) {
            f[k]++;
            g[k]++;
        }
        for (int i = d + 1; i < c / 2; i++) {
            if (a[i] != a[c - i - 1]) {
                f[a[c - i - 1]]++;
                g[a[i]]++;
            }
        }
        if (funcija(f) or funcija(g)) {
            cout << 1;
            return 0;
        }
        int l = 0, m = 0;
        int x = d;
        while (not funcija(f) and x < c) {
            if (x < c / 2)  f[a[x++]]--;
            else f[a[x++]] -= 2;
            l++;
        }
        x = e;
        while (not funcija(g) and x >= 0) {
            if (x >= c / 2) g[a[x--]]--;
            else g[a[x--]] -= 2;
            m++;
        }
        cout << min(l, m);
    } else {
        for (int i = 0; i < c / 2; i++) {
            if (a[i] != a[c - i - 1]) {
                d = i;
                e = c - i - 1;
                f[a[e]]++;
                g[a[d]]++;
                break;
            }
        }
        for (int i = d + 1; i < c / 2; i++) {
            if (a[i] != a[c - i - 1]) {
                f[a[c - i - 1]]++;
                g[a[i]]++;
            }
        }
        if (funcija(f) or funcija(g)) {
            cout << 1;
            return 0;
        }
        int l = 0, m = 0;
        int x = d;
        while (not funcija(f) and x < c) {
            if (x < c / 2) f[a[x++]]--;
            else f[a[x++]] -= 2;
            l++;
        }
        x = e;
        while (not funcija(g) and x >= 0) {
            if (x >= c / 2) g[a[x--]]--;
            else g[a[x--]] -= 2;
            m++;
        }
        cout << min(l, m);
    }
    return 0;
}