#include <bits/stdc++.h>
using namespace std;
bool check1[125], check2[125];
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cerr.tie(0); cout.tie(0);
	string s;
	cin >> s;
	long long res = 1;
	long long n = s.length();
	for(int i = 0; i < n / 2; i++){
		if(s[i] == s[n - i - 1])
			continue;
		else{
			// pokusaj za pola stringa
			long long levi[123];
			long long desni[123];
			long long rez = pow(10,17);
			for(int j = 90; j < 123; j++){
				levi[j] = 0;
				desni[j] = 0;
			}
			long long sum = 0;
			bool pal = true;
			for(int j = i; j < n / 2; j++){
				levi[s[j]]++;
				desni[s[n - j - 1]]++;
				if(levi[s[j]] == desni[s[j]])
					sum--;
				if(levi[s[j]] != desni[s[j]])
					sum++;
				if(levi[s[n - j - 1]] == desni[s[n - j - 1]])
					sum--;
				if(levi[s[n - j - 1]] != desni[s[n - j - 1]])
					sum++;
				cout << "j: " << j << endl;
				for(int j = 97; j < 123; j++)
					cout << levi[j] << " ";
				cout << endl;
				for(int j = 97; j < 123; j++)
					cout << desni[j] << " ";
				cout << endl << sum << endl << endl;
				cout << "prvi " << j << endl;
				if(sum <= 0){
					long long pom = 1;
					for(int a = j + 1; a < n - j - 1; a++){
						cout << a << " " << n - a - 1 << endl;
						pom++;
						if(s[a] != s[n - a - 1] && a < n - a - 1){
							cout << "nije" << a << " " << n - a - 1 << endl;
							pal = false;
							break;
						}
					}
					cout << endl << endl << "u prvom sam: " << j << endl << endl;
					if(pal)
						rez = j + 1 - i;
					break;
				}
			}
			cout << rez << endl;
			// pokusaj za vise od pola stringa
			long long uk[123];
			for(int j = 90; j < 123; j++)
				uk[j] = 0;
			for(int j = i; j < n - i; j++)
				uk[s[j]]++;
			for(int j = 97; j < 123; j++)
				cout << uk[j] << " ";
			for(int j = 90; j < 123; j++){
				desni[j] = 0;
				levi[j] = 0;
			}
			sum = 0;
			for(int k = 97; k < 123; k++){
				if(uk[k] > 0)
					sum++;
			}
			cout << endl << sum;
			cout << endl << endl;
			for(int j = n - i - 1; j >= i; j--){
				desni[s[j]]++;
				uk[s[j]]--;
				for(int k = 97; k < 123; k++)
					cout << uk[k] << " ";
				cout << endl;
				for(int k = 97; k < 123; k++)
					cout << desni[k] << " ";
				if(desni[s[j]] >= uk[s[j]] && !check1[s[j]]){
					sum--;
					check1[s[j]] = true;
				}
				if(sum == 0){
					rez = min(rez, n - (long long)j - (long long)i);
					cout << "j je " << j << endl;
									cout << "drugi: " << n - (long long)j - (long long)i << endl;
					break;
				}
				cout << sum;
				cout << endl << endl;
			}


			for(int j = 90; j < 123; j++)
				uk[j] = 0;
			for(int j = i; j < n - i; j++)
				uk[s[j]]++;
			for(int j = 97; j < 123; j++)
				cout << uk[j] << " ";
			for(int j = 90; j < 123; j++){
				desni[j] = 0;
				levi[j] = 0;
			}
			sum = 0;
			for(int k = 97; k < 123; k++){
				if(uk[k] > 0)
					sum++;
			}
			cout << endl << sum;
			cout << endl << endl;
			for(int j = i; j <= n - i - 1; j++){
				desni[s[j]]++;
				uk[s[j]]--;
				for(int k = 97; k < 123; k++)
					cout << uk[k] << " ";
				cout << endl;
				for(int k = 97; k < 123; k++)
					cout << desni[k] << " ";
				if(desni[s[j]] >= uk[s[j]] && !check2[s[j]]){
					sum--;
					check2[s[j]] = true;
				}
				cout << sum << " " << i;
				if(sum == 0){
					rez = min(rez, (long long)j - (long long)i + 1ll);
					cout << "treci: " << (long long)j - (long long)i + 1ll << endl;
					break;
				}
				cout << " j: " << j << endl;
			}




			cout << endl << endl << rez;
			break;
		}
	}
	return 0;
}