#include #include #include using namespace std; using ll = long long; using ull = unsigned long long; #define rep(i,n) for(int i=0; i<(n); i++) int main(){ string S; cin >> S; string rS = S; reverse(S.begin(),S.end()); if(S != rS){ cout << S.size() << "\n"; return 0; } if(S == string(S.size(),S[0])){ if(S.size() % 2 == 0) cout << "0\n"; else cout << "-1\n"; return 0; } if(S.size() == 3){ cout << "-1\n"; return 0; } cout << (S.size() - 2) << "\n"; return 0; }