#include using namespace std; int main(){ string S; cin >> S; string S2 = S; reverse(S2.begin(), S2.end()); if (S != S2){ cout << S.size() << endl; } else if (S.size() == 1){ cout << -1 << endl; } else { S.pop_back(); S.pop_back(); S2.erase(S2.begin()); S2.erase(S2.begin()); if (S != S2){ cout << S.size() << endl; } else { for (int i = 0; i < S.size(); i++){ assert(S[i] == S[0]); } if (S.size() % 2 == 0){ cout << 0 << endl; } else { cout << -1 << endl; } } } }