#include <bits/stdc++.h>
const long long LINF = 1e18;
const int INF = 1e9;
const int M = 1e9 + 7;
const double EPS = 1e-9;
using namespace std;
int main(int argc, const char* argv[]) {
  std::ios_base::sync_with_stdio(0);
  string s, s1;
  cin >> s;
  s1 = s;
  reverse(s1.begin(), s1.end());
  if (s != s1)
    cout << s.size();
  else {
    int flag = 0;
    char k = s[0];
    for (int i = 0; i < (int)(s.size()); i++) {
      if (s[i] != k) flag = 1;
    }
    if (flag)
      cout << s.size() - 1;
    else
      cout << 0;
  }
  return 0;
}
