#include <bits/stdc++.h>
using namespace std;
int main() {
  int len, c = 0, c1 = 0;
  char s[51];
  cin >> s;
  len = strlen(s);
  for (int i = 0; i < len - 1; i++) {
    if (s[i] == s[i + 1]) {
      c++;
    }
  }
  if (c == len - 1) {
    cout << "0";
  } else if (len == 1) {
    cout << "0";
  } else {
    for (int i = 0; i < len / 2; i++) {
      if (s[i] == s[len - 1 - i]) {
        c1++;
      } else {
        cout << len;
        break;
      }
    }
    if (c1 == len / 2) {
      cout << len - 1;
    }
  }
}
