#include<bits/stdc++.h>

using namespace std;

int pniska(string t){
    int a  = t.length();
    int br = 0;
    for(int i = 0;i < a/2;i++){
        int lev = i;
        int des = a - i -1;
        while(lev < des){
            if(t[lev] ==t[des]) break;
            else des--;
        }
        if(lev == des) return -1;
        for(int j =des;j < a-lev-1;j++){
            swap(t[j],t[j+1]);
            br++;
    } }
        return br;
}
int main()

{
    string t;
    cin >> t;

    int a = pniska(t);
    reverse(t.begin(), t.end());
    int b = pniska(t);

    int res = max(a , b);
    if(res == 0)
        cout << 1;
    else cout << res;






    return 0;
}