#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b = 0, c = 0, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, t, u,
               v, w, x, y, z;
  string s;
  cin >> s;
  a = s.size();
  for (i = 0; i < a / 2; i++) {
    if (s[i] == s[a - i - 1]) {
      b = b + 1;
    }
  }
  for (i = 0; i < a - 1; i++) {
    if (s[i] == s[i + 1]) {
      c = c + 1;
    }
  }
  if (c + 1 == a) {
    cout << "0";
    return 0;
  }
  if (b == a / 2) {
    cout << a - 1;
    return 0;
  } else {
    cout << a;
    return 0;
  }
}
