#include <bits/stdc++.h>
using namespace std;
int main() {
  char a[55];
  scanf("%s", a);
  int len = strlen(a);
  int count = 0, c = 0;
  for (int i = 0; i < len - 1; i++) {
    if (a[i] == a[i + 1]) count++;
  }
  for (int i = 0; i < len; i++) {
    if (a[i] != a[len - i - 1]) {
      c++;
    }
  }
  if (count == len - 1)
    cout << 0 << endl;
  else if (c == 0)
    cout << len - 1 << endl;
  else
    cout << len << endl;
  return 0;
}
