#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<iostream>
#include<string.h>
using namespace std;
int main() {
	string str, st;
	cin >> str;
	int len = str.length(), i, j;
	st = str;
	for (i = 0, j = len - 1; i != j && i != j - 1; i++, j--) {
		if (str[i] == str[j]) {
			st = str.substr(i + 1, len - 2 * i - 2);
		}
		else break;
	}
	len = st.length();
	char l = st[0], r = st[len - 1];
	int az[26], azl[26], azr[26];
	int len2 = len - len / 2;
	for (i = 0; i < 26; i++) {
		az[i] = 0; azl[i] = 0; azr[i] = 0;
	}
	int lc = 0, rc = 0;
	bool br = false;
	for (i = 0; i < len; i++) {
		az[int(st[i] - 97)]++;
	} bool p = false;
	for (i = 0; i <= len / 2; i += 1) {
		azl[int(st[i] - 97)]++;
		if (azl[int(st[i] - 97)] * 2 > az[int(st[i] - 97)]) {
			br = true;
		}
		if (br)break;
		if (i = len / 2) p = true;
		lc++;
	}
	br = false;
	if (len % 2 == 0) {
		i -= 2;
		if (!br) {
			for (j = i + 1; j < len && i != 0; j++, i--) {
				if (st[i] == st[j]) {
					lc++;
				}
				else {
					break;
				}
			}
		}
		len2 = len / 2;
	}
	else {
		i--;
		len2 = len - (len / 2);
		if (az[int(st[i + 1] - 97)] % 2 == 1 && !br) {
			lc++;
			for (j = i + 2; j < len && i != 0; j++, i--) {
				if (st[i] == st[j]) {
					lc++;
				}
				else break;
			}
		}
	}
	p = false;

	for (i = len - 1; i > len2; i--) {
		azr[int(st[i] - 97)]++;
		if (azr[int(st[i] - 97)] * 2 > az[int(st[i] - 97)]) {
			br = true;
		}
		if (br)break;
		if (i - 1 == len2) p = true;
		rc++;
	}
	if (len / 2 == len2) {
		i--;
		if (!br) {
			for (j = i - 1; j != 0 && i < len; i++, j--) {
				if (st[i] == st[j]) {
					rc++;
				}
				else break;
			}
		}
	}
	else {
		i--;
		if (az[int(st[i - 1] - 97)] % 2 == 1 && !br) {
			rc++;
			for (j = i - 2; j != 0 && i < len; i++, j--) {
				if (st[i] == st[j]) {
					rc++;
				}
				else break;
			}
		}
	}
	cout << min(len - rc, len - lc) << "\n";
}