#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main(){
	string s;
	
	cin >> s;
	
	int L = s.length();
	int halfL;
	if (L % 2 == 1){
		halfL = (L - 1) / 2;
	}else{
		halfL = L / 2;
	}
	bool yes[halfL];
	
	for (int i = 0; i < halfL; i++){
		yes[i] = (s[i] == s[L - 1 - i]);
	}
	
	int sol;
	
	int a = -1, b = -1;
	string search = "a";
	for(int i = 0; i < halfL; i++){
		if ((search == "a") and (yes[i] == 0)){
			a = i;
			b = i;
			search = "b";
		}else if ((search == "b") and (yes[i] == 0)){
			b = i;
		}
	}
	
	string s1 = s.substr(0, halfL + 1);
	string s2;
	if (L % 2 == 0) s2 = s.substr(halfL - 1, L - 1);
	else s2 = s.substr(halfL, L - 1);
	sort(s1.begin(), s1.end());
	sort(s2.begin(), s2.end());
	
	bool sim = (s1 == s2);
	
	int f1, f2, f, i = 0;
	bool sure = true;
	string spart;
	
	while (sure){
		spart = s.substr(i + 1 + a, L - 1 - a);
		size_t found = spart.find(s[i + a]);
		if (found == string::npos){
			f1 = i + a;
			sure = false;
			break;
		}
		i++;
	}
	
	sure = true;
	i = L - 1;
	
	while (sure){
		spart = s.substr(0 + a, i - 1 - a);
		size_t found = spart.find(s[i - a]);
		if (found == string::npos){
			f2 =  L - 1 - i + a;
			sure = false;
			break;
		}
		i--;
	}
	
	if (f1 > halfL) f = f2;
	else if (f2 > halfL) f = f1;
	else if (f1 > f2) f = f1;
	else f = f2;
	
	if (a == -1){
		sol = 1;
	}else if (sim){
		sol = b - a + 1;
	}else{
		sol = L - 2 * a - f;
	}
	cout << sol;
}