#include <bits/stdc++.h>
int main() {
  char s[51];
  scanf("%s", s);
  int p = 1, len = strlen(s);
  for (int i = 0, j = len - 1; i < j; i++, j--) {
    if (s[i] != s[j]) {
      p = 0;
      break;
    }
  }
  if (!p)
    printf("%d\n", len);
  else {
    int d = 1;
    for (int i = 1; s[i] != '\0'; i++) {
      if (s[i] != s[i - 1]) {
        d = 0;
        break;
      }
    }
    if (!d)
      printf("%d\n", len - 1);
    else
      printf("0\n");
  }
}
