#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
const ll mod2=998244353;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

const int N=205000;
char s[N],t[N];
int n;

/*bool pal() {
	rep(i,0,n) if (t[i]!=t[n-i-1]) return false;
	return true;
}*/

/*int bans;
void bf() {
	VI p(n);
	iota(all(p),0);
	bans=n;
	do {
		rep(i,0,n) t[i]=s[p[i]];
		int l=0,r=-1;
		per(i,0,n) if (p[i]!=i) l=i;
		rep(i,0,n) if (p[i]!=i) r=i;
		if (pal()) {
			bans=min(bans,r-l+1);
		}
	} while (next_permutation(all(p)));
	bans=max(bans,1);
	printf("%d\n",bans);
}*/

/*bool valid() {
	VI cnt(26);
	rep(i,0,n) cnt[s[i]-'a']++;
	int ss=0;
	rep(i,0,n) ss+=(cnt[i]%2);
	return ss<=1;
}*/

int main() {
	scanf("%s",s);
	n=strlen(s);
		int suc=1;
		rep(i,0,n) if (s[i]!=s[n-i-1]) suc=0;
		if (suc) {
			puts("1");
			return 0;
		}
		int x=0;
		while (s[x]==s[n-x-1]) x++;
		int y=(n-1)/2;
		while (s[y]==s[n-y-1]) y--;
		int l=x,r=n-x-1,ans=r-l+1;
		VI pp(26),qq(26);
		rep(i,l,y+1) pp[s[i]-'a']++;
		rep(i,n-y-1,r+1) qq[s[i]-'a']++;
		bool kroz=0;
		rep(i,0,26) if (pp[i]!=qq[i]) kroz=1;
		if (kroz) {
			rep(i,0,26) pp[i]=qq[i]=0;
	 		rep(i,l,r+1) qq[s[i]-'a']++;
	 		int cc=0;
			rep(i,0,26) if (pp[i]<qq[i]) cc++;
			rep(i,l,r+1) {
	 			int ch=s[i]-'a';
	 			bool w1=(pp[ch]<qq[ch]);
	 			//if (qq[ch]-pp[ch]>=0&&qq[ch]-pp[ch]<=2) cc--;
				pp[s[i]-'a']++;
				qq[s[i]-'a']--;
				bool w2=(pp[ch]<qq[ch]);
				if (w1!=w2) cc--;
				//if (pp[s[i]-'a']<qq[s[i]-'a']) break;
				int suc=1;
				if (i<y) suc=0;
				if (cc!=0) suc=0;
				//rep(j,0,26) if (pp[j]<qq[j]) suc=0;
				if (suc) ans=min(ans,i-l+1);
			}
			cc=0;
			rep(i,0,26) if (pp[i]>qq[i]) cc++;
			y=n-y-1;
			//rep(i,0,26) assert(pp[i]<=qq[i]);
			per(i,l,r+1) {
				int ch=s[i]-'a';
				bool w1=(pp[ch]>qq[ch]);
				//if (pp[ch]-qq[ch]>=0&&pp[ch]-qq[ch]<=2) cc--;
				qq[s[i]-'a']++;
				pp[s[i]-'a']--;
				bool w2=(pp[ch]>qq[ch]);
				if (w1!=w2) cc--;
				//printf("i:%d  %d  ",i,cc);
				//int act=0;
				//rep(j,0,26) if (pp[j]>qq[j]) act++;
				//printf("%d\n",act);
				//if (pp[s[i]-'a']>qq[s[i]-'a']) break;
				int suc=1;
				if (i>y) suc=0;
				if (cc!=0) suc=0;
				//rep(j,0,26) if (pp[j]>qq[j]) suc=0;
				if (suc) ans=min(ans,r-i+1);
			}
			printf("%d\n",ans);	
			/*if (bans!=ans) {
				printf("BAAAN\n");
				return 0;
			}*/
		} else {
			printf("%d\n",y-l+1);
			/*if (bans!=y-l+1) {
				printf("BAAAN\n");
				return 0;
			}
		}*/
	}	
}
/*
abcabca
*/