#include <bits/stdc++.h>
using namespace std;
int main() {
  long long l;
  string s;
  cin >> s;
  int i = 0;
  l = s.length();
  for (int i = 0; i < l - 1; i++) {
    if (s[i] != s[i + 1]) break;
    if (s[i] == s[l - 1] && i + 1 == l - 1) {
      cout << "0";
      exit(0);
    }
  }
  l--;
  while (i < l) {
    if (s[i++] == s[l--])
      continue;
    else {
      cout << s.length();
      exit(0);
    }
  }
  cout << s.length() - 1;
}
