#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void ZZ(const char* name, Arg1&& arg1) {
  std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  std::cerr.write(names, comma - names) << " = " << arg1;
  ZZ(comma, args...);
}
int main() {
  string s, t;
  long long f = 0;
  cin >> t;
  s = t;
  set<char> se;
  reverse(t.begin(), t.end());
  for (long long i = 0; i < s.size(); i++) {
    se.insert(s[i]);
    if (s[i] != t[i]) f = 1;
  }
  if (se.size() == 1)
    cout << 0;
  else if (f == 0)
    cout << s.size() - 1;
  else
    cout << s.size();
  return 0;
}
