#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) {
	auto start = x.begin() + p;
	auto end = x.begin() + p + n;
	for (int i = 1; i < n; i++) 
	{
		auto f = find(start, end, x[x.length() - p - i]);
		if (f != end) {
			iter_swap(f, x.begin()+p);
			if (is_palindrome(x)) return true;
		}
		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 = 2; i < a.length(); i++)
		for (int j = 0; j <= a.length() - i; j++) 
			if (validate(a, i, j)) {
				cout << i << "\n";
				return 0;
			}
}