#include <bits/stdc++.h>
using namespace std;
inline int mn(int a, int b) { return a < b ? a : b; }
int main() {
  std::ios::sync_with_stdio(false);
  int i, n, m, k, t;
  string x;
  cin >> x;
  int l = 0;
  int r = x.length() - 1;
  while (l < r) {
    if (x.at(l) != x.at(r)) {
      cout << x.length();
      return 0;
    }
    l++;
    r--;
  }
  for (i = 1; i < x.length(); i++) {
    if (x.at(i) != x.at(i - 1)) {
      cout << x.length() - 1;
      return 0;
    }
  }
  cout << "0";
  return 0;
}
