#include <bits/stdc++.h>
using namespace std;
bool ispalin(string second) {
  for (int i = 0; i < (int)second.length(); i++) {
    if (second[i] != second[second.length() - i - 1]) return false;
  }
  return true;
}
int main() {
  string second;
  cin >> second;
  bool x = ispalin(second);
  if (x == false)
    cout << second.length() << "\n";
  else {
    set<char> st;
    for (int i = 0; i < (int)second.length(); i++) {
      st.insert(second[i]);
    }
    if (st.size() == 1)
      cout << "0";
    else
      cout << (second.size() - 1) << '\n';
  }
}
