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

string palindrom(string t){
    string p = t;
    reverse(p.begin(), p.end());
    if(p == t) return "da";
    else return "ne";
}

string napraviP(string t)
{
    unordered_map<char, int> hmap;
    for (int i = 0; i < t.length(); i++)
        hmap[t[i]]++;


    int neparniBr = 0;
    char nepKar;
    for (auto x : hmap) {
        if (x.second % 2 != 0) {
            neparniBr++;
            nepKar = x.first;
        }
    }

    if (neparniBr > 1
        || neparniBr == 1 && t.length() % 2 == 0)
        return "ne";

    string polovina1 = "", polovina2 = "";
    for (auto x : hmap) {
        string s(x.second / 2, x.first);
        polovina1 += s;
        polovina2 = s + polovina2;
    }
    return (neparniBr == 1)
               ? (polovina1 + nepKar + polovina2)
               : (polovina1 + polovina2);
}

int uporedi(string t, string paT){
    int ok = 0;
    int n = t.length();
    for(int i = 0; i < n; i ++){
        const char c1 = t[i];
        const char c2 = paT[i];
        if(c1 == c2) ok ++;
        else break;
    }
    for(int i = n - 1; i >= 0; i --){
        const char c1 = t[i];
        const char c2 = paT[i];
        if(c1 == c2) ok ++;
        else break;
    }
    return ok;
}

string pa(string t){
    int n = t.length();string p = t;
    int j = n;
    string polovina1 = "", polovina2 = "";
    for(int i = 0; i < n; i++){
        const char c1 = t[i];
        const char c2 = t[j];
        if(c1 != c2){ int x = j; t[j] = t[i]; t[x-1] = t[x]; }
        j --;
    }

    reverse(p.begin(), p.end());
    if(p == t) return p;
}

string w(string t, string paT){
    int n = t.length();
    for(int i = 0; i < n; i ++){
        const char c1 = t[i];
        const char c2 = paT[i];

        if(c1 == paT[i+1]){
            const char o = paT[i +1];
            paT[i + 1] = paT[i];
            paT[i] = o;
        }
    }
    return paT;
}

int main()
{
    string t;
    cin >> t;
    int dane = 0, br_slova = 0;
    br_slova = t.length();
    string paT, lmao;
    int broj = br_slova;
    bool idk = false;

    if(palindrom(t) == "da") dane = 1;
    else {
        paT = napraviP(t);
        lmao = w(t,paT);
        if(palindrom(lmao) == "da"){
            broj = uporedi(t,lmao);
        }
        else {
            lmao = napraviP(lmao);
            broj = uporedi(t,lmao);
        }
        dane = br_slova - broj;
    }
    cout << dane;

    return 0;
}