#include<iostream>
#include<string>
using namespace std;
main()
{
	char c[200000];
	cin>>c;
	string T=c;
	int n=T.size();
	int i=0;
	int j=n-1;
	while(i<n/2)
	{
		if(T.at(i)!=T.at(j))
		{
			if(T.at(i)!=T.at(i+1)&&T.at(j)!=T.at(j-1))
			{
			break;
			}
			else 
			{
			if(T.at(i)==T.at(i+1)) i++;
			if(T.at(j)==T.at(j-1)) j--;
			}
		}
		else
		{i++;j--;}	
	}
	cout<<j-i+1;
}