#include <iostream>
#include <map>

using namespace std;

int main()
{
	string t;
	cin >> t;
	map<char, int> m;
	map<char, int> mi;
	const int tl = t.length();
	const int mirror = tl - 1;
	string ti(tl, '*');
	for (int i = 0; i < tl; i++)
	{
		char c = t[i];
		m[c]++;
		mi[c]++;
		ti[mirror - i] = c;
	}
	string u(tl, '*');
	string ui(tl, '*');
	int k = 0;
	for (int i = 0; i < tl; i++)
	{
		char c = t[i];
		if (m[c] > 1)
		{
			u[k] = c;
			u[mirror - k] = c;
			m[c] -= 2;
			k++;
		}
		else if (m[c] == 1)
		{
			u[tl / 2] = c;
		}
	}
	k = 0;
	for (int i = 0; i < tl; i++)
	{
		char c = ti[i];
		if (mi[c] > 1)
		{
			ui[k] = c;
			ui[mirror - k] = c;
			mi[c] -= 2;
			k++;
		}
		else if (mi[c] == 1)
		{
			ui[tl / 2] = c;
		}
	}
	int x = 0;
	for (int i = 0; i < tl; i++)
	{
		if (t[i] != u[i])
		{
			x = i;
			break;
		}
	}
	int y = 0;
	for (int i = tl - 1; i >= 0; i--)
	{
		if (t[i] != u[i])
		{
			y = i;
			break;
		}
	}
	int r = y - x + 1;
	x = 0;
	for (int i = 0; i < tl; i++)
	{
		if (ti[i] != ui[i])
		{
			x = i;
			break;
		}
	}
	y = 0;
	for (int i = tl - 1; i >= 0; i--)
	{
		if (ti[i] != ui[i])
		{
			y = i;
			break;
		}
	}
	int r1 = y - x + 1;
	if (r1 > r)
	{
		cout << r;
	}
	else
	{
		cout << r1;
	}
}