#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  long long x = s.size();
  long long counter = 0;
  for (int i = 1; i < x; i++) {
    if (s[i] == s[i - 1]) {
      counter++;
    }
  }
  if (counter == x - 1) {
    cout << 0 << endl;
  } else {
    int flag = 0;
    for (int i = 0; i < x; i++) {
      if (s[i] != s[x - i - 1]) {
        flag = 1;
        break;
      }
    }
    if (flag == 1) {
      cout << x << endl;
    } else {
      cout << x - 1 << endl;
    }
  }
  return 0;
}
