#include<bits/stdc++.h>
using namespace std;
 
#define fast ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);cerr.tie(nullptr);
#define pb push_back
#define PI 3.14159265
#define pii pair<int,int>
//#define f first
//#define s second
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;


int d1[26][200005],d2[26];
bool p[200005];

void Solve() {
	string s,q="-1";
	cin >> s;
	int n=s.length();
	for(int i=0;i<n;i++) {
		if(s[i]!=s[n-i-1]) {
			q = s.substr(i,n-2*i);
			break;
		}
	}
	if(q=="-1") {
		cout<<1<<"\n";
		return;
	}
	n=q.length();
	for(int i=n-1;i>=1;i--) {
		for(int j=0;j<26;j++) d1[j][i]=d1[j][i+1];
		d1[q[i]-'a'][i]++;
	}
	int x=n/2;
	while(q[x]==q[n-x-1]) {
		p[x]=1;
		p[n-x-1]=1;
		x--;
	}
	int ans=n;
	for(int i=0;i<n-1;i++) {
		bool ok=true;
		d2[q[i]-'a']++;
		if(p[i+1] && n-i-2>=i+1) {
			for(int j=0;j<26;j++) {
				if(d2[j]!=d1[j][n-i-1]) ok=false;
			}
		if(ok) ans=min(ans,i+1);
		}
		ok=true;
		if(i>=n/2) {
			int iman=0;
		for(int j=0;j<26;j++) {
			if(d1[j][i+1]>d2[j]) ok=false;
			else {
				int y=d2[j]-d1[j][i+1];
				if(y%2==1) iman++;
			}
		}
		if(iman) {
			if(n%2==0) ok=false;
			else {
				if(iman>1) ok=false;
			}
		}
		if(ok) ans=min(ans,i+1);
	    }
	    else {
	    //	cout<<i<<"\n";
	    	int iman=0;
		for(int j=0;j<26;j++) {
			if(d1[j][i+1]<d2[j]) ok=false;
			else {
				int y=-(d2[j]-d1[j][i+1]);
				//cout<<j<<" "<<y<<"\n";
				if(y%2==1) iman++;
			}
		}
		//cout<<iman<<" "<<n-i-1<<"\n";
		if(iman) {
			if(n%2==0) ok=false;
			else {
				if(iman>1) ok=false;
			}
		}
		if(ok) {
			//cout<<"uso"<<"\n";
			ans=min(ans,n-i-1);
		}
		}
	}
	cout<<ans;
	
}
//0123456

int main()
{
	//fasti
	int tt=1;
    //cin >> tt;
	while(tt--) {
		Solve();
	}
	
	
}