#include <iostream>
#include <algorithm>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int t[27];

string skini(string s){
	int p=0,d=s.length()-1;
	while(s[p]==s[d] and p<d and p!=d){
		p++;
		d--;
	}
	s=s.substr(p,d+1-p);
	return s;
}

bool minusjedan(int a[], int in){
	for(int i=0;i<26;i++){
		if(a[i]!=0 and i!=in){
			return false;
		}
	}
	return true;
}

int levikrece(string s,int a[]){
	int aa[27];
	int p=a[0];
	for(int i=0;i<26;i++){
		aa[i]=a[i];
	}
	if(aa[s[0]-'a']>=2){
		aa[s[0]-'a']-=2;
		return levikrece(s.substr(1,s.length()-1),aa);
	}
	if(minusjedan(a,s[0]-'a')){
		return s.length()-1;
	}
	return s.length();
}

int desnikrece(string s,int a[]){
	int aa[27];
	int n=s.length();
	int p=a[n-1];
	for(int i=0;i<26;i++){
		aa[i]=a[i];
	}
	if(aa[s[n-1]-'a']>=2){
		aa[s[n-1]-'a']-=2;
		return desnikrece(s.substr(0,n-1),aa);
	}
	if(minusjedan(a,s[n-1]-'a')){
		return s.length()-1;
	}
	return s.length();
}

int main(int argc, char** argv) {
	ios_base::sync_with_stdio(false);
	string s;
	cin>>s;
	s=skini(s);
	int n=s.length();
	int l=0,d=s.length()-1;
	bool ok=true;
	for(int i=0;i<26;i++){
		t[i]=0;
	}
	for(int i=0;i<n;i++){
		t[s[i]-'a']++;
	}
	
	int res=0;
	if(s.length()==1 or s.length()==0){
		cout<<1;
		return 0;
	}
	int levo=levikrece(s,t);
	int desno=desnikrece(s,t);
	//cout<<levo<<" "<<desno;
	cout<<min(levo,desno);
	return 0;
}