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

int main()
{
    string s; cin>>s;
    string s1=s;
    int n = s.length();
    int br=0;
    int br1;
    int br2;
    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 - d - 1; j++) {
            swap(s[j], s[j + 1]);
            br++;
        }
    }
    
    for(int i=0; i<s.length(); i++){
        if(s1[i]!=s[i]){
            br1=i;
            break;
        }
    }
    for(int i=0; i<s.length(); i++){
        if(s1[i]!=s[i]){
            br2=i+1;
        }
    }
    if(br ==0){
        cout<<"1";
    }else
        cout<<br2-br1;
}