#include using namespace std; int main () { string S; cin >> S; int N = S.size(); for (int i = 0; i < N; i ++) { if (S[i] != S[N - i - 1]) { cout << N << endl; return 0; } } for (int i = 0; i < N / 2 - 1; i ++) { if (S[i] != S[i + 1]) { cout << N - 2 << endl; return 0; } } cout << (N % 2 ? -1 : 0) << endl; }