#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  bool palindrom = true;
  for (int i = 0; i < ceil(s.length() / 2.0); i++) {
    if (s[i] != s[s.length() - 1 - i]) palindrom = false;
  }
  if (!palindrom) {
    cout << s.length() << "\n";
    return 0;
  }
  char elso = s[0];
  bool mind_ugyanaz = true;
  for (auto c : s) {
    if (c != elso) mind_ugyanaz = false;
  }
  if (mind_ugyanaz)
    cout << "0\n";
  else
    cout << s.length() - 1 << "\n";
}
