#include #include #include #include #include #include #include #include #include #include #include #include #define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl; #define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } using namespace std; typedef long long ll; bool judge(string s){ int n = s.size(); for(int i = 0; i < n; i++){ if(s[i] != s[n-i-1]) return false; } return true; } int main(){ ios::sync_with_stdio(false); cin.tie(0); cout << setprecision(10) << fixed; set st; string s; cin >> s; if(s.size() <= 1){ cout << -1 << endl; return 0; } for(char c: s) st.insert(c); if(st.size() == 1){ if(s.size()%2 == 0) cout << 0 << endl; else cout << -1 << endl; return 0; } if(judge(s)){ cout << s.size()-2 << endl; }else{ cout << s.size() << endl; } }