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

int main(){
  
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    string s;

    cin >> s;

    int n = s.size();
    
    int ans1 = 0, ans2 = 0;

    int i = 0, j = n-1, fL = 0, fR = n-1;
    bool setL = 0, setR = 0;

    string sCp = s;
    while(i < j){
        if(s[i] != s[j]){
            if(!setL) fL = i;
            int ind = -1;
            for(int tmp = i+1; tmp < j; ++tmp){
                if(s[tmp] == s[j]) { ind = tmp; break; }
            }
            if(ind != -1){
                if(ind > fL) ans1 += ind-fL, fL = ind;
                if(!setL) ++ans1, setL = 1;
            }else{
                if(j > fL){
                    ans1 += j-fL;
                    if(!setL) ++ans1;
                    break;
                }
            }

            char tmp = s[i];
            s[i] = s[ind];
            s[ind] = tmp;
        }
        ++i, --j;
    }

    i = 0, j = n-1;

    s = sCp;

    while(i < j){
        if(s[i] != s[j]){
            if(!setR) fR = j;
            int ind = -1;
            for(int tmp = j-1; tmp > i; --tmp){
                if(s[tmp] == s[i]) { ind = tmp; break; }
            }
            if(ind != -1){
                if(ind < fR) ans2 += fR-ind, fR = ind;
                if(!setR) ++ans2, setR = 1;
            }else{
                if(i < fR){
                    ans2 += i-fR;
                    if(!setR) ++ans2;
                    break;
                }
            }
            char tmp = s[j];
            s[j] = s[ind];
            s[ind] = tmp;
        }
        ++i, --j;
    }
    
    ans1 = min(ans1, ans2);

    cout << (ans1 == 0 ? 1 : ans1) << '\n';
    return 0;
}