#include <bits/stdc++.h>
using namespace std;
int main() {
  string s = "";
  cin >> s;
  bool pal = true;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] != s[s.size() - i - 1]) pal = false;
  }
  if (pal == false)
    cout << s.size();
  else {
    int index = -1;
    for (int i = 0; i < s.size() - 1; i++) {
      if (s[i] != s[i + 1]) {
        cout << s.size() - 1;
        return 0;
      }
    }
    cout << "0";
  }
  return 0;
}
