#include int main() { using namespace std; cin.tie(nullptr)->sync_with_stdio(false); string s; cin >> s; int n = size(s); if (count(begin(s), end(s), s[0]) == n) { cout << "-1\n"; exit(0); } if (s != string(rbegin(s), rend(s))) { cout << n << '\n'; exit(0); } cout << n - 2 << '\n'; }