#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];

int main() {
	scanf("%s",s);
	int 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/2;
	while (s[y]==s[n-y-1]) y--;
	int l=x,r=n-x-1,ans=r-l+1;
	//printf("%d %d %d\n",l,r,y);
	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;
	/*rep(i,0,26) {
		printf("pp[%d]=%d, qq[%d]=%d\n",i,pp[i],i,qq[i]);
	}*/
	//puts(kroz?"lol":"ne");
 	if (kroz) {
 		rep(i,0,26) pp[i]=qq[i]=0;
 		rep(i,l,r+1) qq[s[i]-'a']++;
 		rep(i,l,r+1) {
			pp[s[i]-'a']++;
			qq[s[i]-'a']--;
			int suc=1;
			if (i<y) suc=0;
			rep(j,0,26) if (pp[j]<qq[j]) suc=0;
			if (suc) ans=min(ans,i-l+1);
		}
		y=n-y-1;
		per(i,l,r+1) {
			qq[s[i]-'a']++;
			pp[s[i]-'a']--;
			int suc=1;
			if (i>y) suc=0;
			rep(j,0,26) if (pp[j]>qq[j]) suc=0;
			if (suc) ans=min(ans,r-i+1);
		}
		printf("%d",ans);	
	} else printf("%d",y-l+1);
	
}