#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  bool isPal, allSame;
  isPal = true;
  allSame = true;
  char c = s[0];
  for (int i = 1; i < s.size(); i++) {
    if (s[i] != c) {
      allSame = false;
      break;
    }
  }
  if (allSame) {
    cout << 0;
    return 0;
  }
  int l = 0;
  int r = s.size() - 1;
  while (l < r) {
    if (s[l] == s[r]) {
      ++l;
      --r;
    } else {
      cout << s.size();
      return 0;
    }
  }
  cout << s.size() - 1;
  return 0;
}
