#include int is_palindrome(char S[]) { int i, j; for (j = 0; S[j] != 0; j++); for (i = 0, j--; i < j; i++, j--) if (S[i] != S[j]) break; if (i < j) return 0; else return 1; } int is_unique(char S[]) { int i; for (i = 1; S[i] != 0; i++) if (S[i] != S[0]) break; if (S[i] != 0) return 0; else return 1; } int main() { int l; char S[1000001]; scanf("%s", S); for (l = 0; S[l] != 0; l++); if (is_palindrome(S) == 0) printf("%d\n", l); else if (is_unique(S) != 0) printf("%d\n", l - 2); else if (l % 2 == 0) printf("0\n"); else printf("-1\n"); fflush(stdout); return 0; }