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

int obrni(string s){
    int n = s.length();
    int brojac = 0;
    for (int i = 0; i < n / 2; i++) {
        int l = i;
        int d = n - l - 1;
        while (l < d) {
            if (s[l] == s[d])
                break;
            else
                d--;
        }
        if (l == d)
            return -1;
        for (int j = d; j < n - l - 1; j++) {
            swap(s[j], s[j + 1]);
            brojac++;
        }
    }
    return brojac;
}

int main(){
    string s;
    cin >> s;
    int rez1 = obrni(s);
    reverse(s.begin(), s.end());
    int rez2 = obrni(s);
    if(rez1==0)
        rez1=1;
    if(rez2==0)
        rez2=1;
    cout << max(rez1, rez2);
    return 0;
}