#include <bits/stdc++.h>
using namespace std;
bool pal(string s) {
  for (int i = 0; i < s.length() / 2; i++) {
    if (s[i] != s[s.length() - (i + 1)]) return false;
  }
  return true;
}
int main() {
  string s;
  cin >> s;
  long long cnt = 1;
  char c = s[0];
  for (int i = 1; i < s.length(); i++) {
    if (s[i] == s[0]) cnt++;
  }
  if (cnt == s.length()) {
    cout << 0;
    return 0;
  } else {
    if (pal(s) != true) {
      cout << s.length();
      return 0;
    } else {
      cout << s.length() - 1;
      return 0;
    }
  }
  return 0;
}
