#include <bits/stdc++.h>
using namespace std;
bool ehPalindromo(string s, int i, int j) {
  while (i <= j) {
    if (s[i] != s[j]) return false;
    i++;
    j--;
  }
  return true;
}
bool ehIgual(string s) {
  int cont = 0;
  for (int i = 0; i < int(s.size()); i++) {
    if (s[i] == s[0]) cont++;
  }
  if (cont == int(s.size())) return true;
  return false;
}
int main() {
  string s, new_word = "";
  cin >> s;
  if (ehIgual(s)) {
    cout << 0 << endl;
  } else {
    if (ehPalindromo(s, 0, int(s.size()) - 1)) {
      for (int i = 0; i < int(s.size()) - 1; i++) {
        new_word += s[i];
      }
    } else
      new_word = s;
    cout << int(new_word.size()) << endl;
  }
}
