#include <iostream>

#define IMA_TESTOVE 0

typedef long long ll;

using namespace std;

void solve()
{
	string s;
	cin >> s;
	int l = 0, d = s.length() - 1, a[26] = {},a1[26];
	for (int i = 0; i < s.length(); i++)
	{
		a[s[i] - 97]++;
	}
	while (l <= d && s[l] == s[d])
	{
		l++;
		d--;
	}
	if (l > d)
	{
		cout << 1 << endl;
		return;
	}
	//s leva na desno
	int l1 = l;
	bool t = true;
	copy(begin(a), end(a), begin(a1));
	while (t)
	{
		if (a1[s[l1]-97] - 2 < 0)t = false;
		else
		{
			a1[s[l1] - 97] -= 2;
			l1++;
		}
	}
	//s desna na levo
	int d1 = d;
	t = true;
	while (t)
	{
		if (a[s[d1] - 97] - 2 < 0)t = false;
		else
		{
			a[s[d1] - 97] -= 2;
			d1--;
		}
	}
	cout <<min(d-l1+1,d1-l+1)<< endl;
}

int main()
{
	int t = 1;
	if (IMA_TESTOVE)cin >> t;
	for (int i = 0; i < t; i++)solve();
}