#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>

using namespace std;

int last[26];
int first[26];
int numChars[26];
bool arr[200'005];

int findLast(string &s, char x, int l, int r) {

	int lst = -1;

	for (int i = r; i >= l; i--) {
		if (s[i] == x) {
			lst = i;
			break;
		}
	}

	return lst;

}

int findFirst(string &s, char x, int l, int r) {

	int frst = 1e9;

	for (int i = l; i <= r; i++) {
		if (s[i] == x) {
			frst = i;
			break;
		}
	}

	return frst;

}

int main() {


	for (int i = 0; i < 26; i++) {
		last[i] = -1;
		first[i] = 1e9;
	}

	string os;
	cin >> os;

	string s = "";

	int solvedSize = 0;
	int ns = os.length();


	for (int i = 0; i < ns; i++) {
		if (os[i] == os[ns - 1- i]) {
			solvedSize++;
		} else {
			break;
		}
	}

	for (int i = solvedSize; i < ns - solvedSize; i++) {
		s += os[i];
		numChars[os[i]-'a']++;
	}

	//cout << s << endl;
	int n = s.length();

	for (char i = 'a'; i <= 'z'; i++) {
		last[i-'a'] = findLast(s, i, 0, n - 1);
		first[i-'a'] = findFirst(s, i, 0, n - 1);
		//cout << i << " " << last[i-'a'] << endl;
	}


	char chn2 = '0';
	for (int i = 0; i < n; i++) {
		if (numChars[s[i]-'a'] % 2) {
			chn2 = s[i];
			break;
		}
	}

	// From the left

	int solvedLeft = 0;

	for (int i = 0; i < n; i++) {
		if (s[i] == chn2 and i == n/2) {
			solvedLeft++;
			continue;
		}
		//cout << last[s[i]-'a'] << " " << i << endl;
		if (last[s[i]-'a'] > i) {
			solvedLeft++;
			last[s[i]-'a'] = findLast(s, s[i], i+1, last[s[i]-'a'] - 1);
		} else {
			break;
		}
	}

	//cout << "sl " << solvedLeft << endl;
	//cout << n << endl;

	//cout << s.length() - solvedLeft << endl;

	// From the right
	int solvedRight = 0;

	for (int i = n-1; i >= 0; i--) {
		//cout << "| i = " << i << " | first[s[i] - 'a'] = " << first[s[i] - 'a'] << endl; 
		if (s[i] == chn2 and i == n/2) {
			solvedRight++;
			continue;
		}
		if (first[s[i]-'a'] < i) {
			solvedRight++;
			first[s[i]-'a'] = findFirst(s, 0, s[i], first[s[i]-'a'] - 1);
		} else {
			break;
		}
	}

	cout << max(1, min(n - solvedLeft, n - solvedRight)) << endl;
	// cout << n - solvedLeft << endl;
	// cout << n - solvedRight << endl;
	// cout << n << endl;





	return 0;
}