#include <iostream>
#include <algorithm>
using namespace std;
bool is_palindrome(string a) {
	for (int i = 0; i < a.length() / 2; i++)
		if (a[i] != a[a.length() - 1 - i]) return false;
	return true;
}
bool validate(string x, int n, int p) {
	for (int i = p; i < p+n; i++) 
	{
		auto f = find(x.begin() + i + 1, x.begin() + p + n, x[x.length() - i - 1]);
		if (f != x.begin() + p + n) iter_swap(x.begin() + i, f);
		else return is_palindrome(x);
	}
	return false;
}
int main()
{
	string a;
	cin >> a;
	if (is_palindrome(a)) {
		cout << 1 << "\n";
		return 0;
	}
	for (int i = 1; i < a.length() + 1; i++)
		for (int j = 0; j <= a.length() - i; j++) 
			if (validate(a, i, j)) {
				cout << i << "\n";
				return 0;
			}
}