#include <bits/stdc++.h>
using namespace std;
int main() {
  set<char> st;
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    st.insert(s[i]);
  }
  string a = s;
  reverse(a.begin(), a.end());
  if (st.size() == 1) {
    cout << "0" << endl;
  } else if (s == a) {
    cout << s.size() - 1 << endl;
  } else
    cout << s.size() << endl;
}
