#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  set<char> se;
  string news = s;
  for (int i = 0; i < s.size(); ++i) {
    se.insert(s[i]);
  }
  reverse(s.begin(), s.end());
  if (se.size() == 1) {
    cout << 0;
  } else if (s == news) {
    cout << s.size() - 1;
  } else {
    cout << s.size();
  }
  cout << endl;
}
