#include <bits/stdc++.h> 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 if (S.size() % 2 == 0){ cout << 0 << endl; } else { cout << -1 << endl; } } }