#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long
#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	vector<int> m(26), f(26);
	string t; cin >> t;
	int n = t.length();
	rep(i,n){
		m[t[i]-'a']++;
	}
	int l = 0, r = n-1;
	bool ok = true;
	while(l<n/2){
		if(ok && t[l]==t[r]){
			m[t[l]-'a']-=2;
			if(l+1>=r-1)break;
			l++, r--;
			
		}
		else if(f[t[l]-'a']++<m[t[l]-'a']/2){
			ok = false;
			l++;
		}
		else break;
	}
	int ans1 = r-l+1;
	fill(all(f),0);
	ok = true;
	l = 0, r = n-1;
	while(n%2 && r>n/2||n%2==0 && r>n/2-1){
		if(ok && t[l]==t[r]){
			if(l+1>=r-1)break;
			l++, r--;
			
		}
		else if(f[t[r]-'a']++<m[t[r]-'a']/2){
			ok = false;
			r--;
		}
		else break;
	}
	int ans2 = r-l+1;
	if(ans1==ans2){
		int ans3;
		l=0,r=n/2-1;
		ok =true;
		int s=l, e=r;
		while(l<n/2){
			if(t[l]!=t[n-l-1]){
				s=l;
				ok=false;
				break;
			}
			l++;
		}
		while(r>0){
			if(t[r]!=t[n-r-1]){
				e=r;
				break;
			}
			r--;
		}
		if(ok)ans3=1;
		else ans3= e-s+1;
		cout << ans3;
		return 0;
	}
	
	cout << min(ans1, ans2);
	return 0;
}