#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long INF = 1000000000000000000;
int main(int argc, char const *argv[]) {
  string s;
  cin >> s;
  string ss = s;
  reverse(s.begin(), s.end());
  if (s != ss) {
    cout << s.size();
    return 0;
  }
  int n = s.size();
  sort(s.begin(), s.end());
  if (s[n - 1] == s[0])
    cout << "0";
  else
    cout << n - 1;
  return 0;
}
