#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, r;
  cin >> s;
  long long int ans;
  long long int len = s.length();
  long long int ctr[200] = {0};
  for (long long int i = 0; i < s.length(); i++) {
    ctr[int(s[i])]++;
  }
  for (long long int i = 97; i <= 123; i++) {
    if (ctr[i] == len) {
      cout << 0;
      return 0;
    }
  }
  r = s;
  reverse(r.begin(), r.end());
  if (s == r) {
    ans = len - 1;
  } else {
    ans = len;
  }
  cout << ans;
}
