#include <bits/stdc++.h>
using namespace std;
int i, j, k;
int main() {
  string s;
  cin >> s;
  int df = 0;
  for (i = 0; i < s.size(); i++) {
    if (s[i] != s[0]) df = 1;
    if (s[i] != s[s.size() - 1 - i]) {
      cout << s.size() << endl;
      exit(0);
    }
  }
  cout << (df ? s.size() - 1 : 0) << endl;
}
