#include <bits/stdc++.h>
using namespace std;
bool check_pal(string d) {
  for (int i = 0; i < d.length() / 2; i++) {
    if (d[i] != d[d.length() - i - 1]) {
      return false;
    }
  }
  return true;
}
int main() {
  string s;
  cin >> s;
  int flag_s = 0;
  for (int i = 0; i < s.length() - 1; i++) {
    if (s[i] != s[i + 1]) {
      flag_s = 1;
    }
  }
  if (flag_s == 1) {
    bool a = check_pal(s);
    if (a)
      cout << s.length() - 1 << endl;
    else
      cout << s.length() << endl;
  } else
    cout << "0" << endl;
  return 0;
}
