#include <bits/stdc++.h>
using namespace std;
char gap = 32;
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << '{';
  for (const auto &x : v) os << gap << x;
  return os << '}';
}
template <typename A, typename B>
ostream &operator<<(ostream &os, const pair<A, B> &p) {
  return os << '(' << p.first << gap << p.second << ')';
}
bool chkPalindrome(string s) {
  int r = s.size() - 1;
  int l = 0;
  while (r > l) {
    if (s[l++] != s[r--]) {
      return false;
    }
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int i, j, k;
  string s, st = "", a = "", b = "";
  cin >> s;
  if (chkPalindrome(s) == true) {
    a = s.substr(1, s.size());
    if (chkPalindrome(a) == false)
      cout << a.size();
    else
      cout << "0";
  } else
    cout << s.size();
}
