#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  for (int i = 0; i < s.length() / 2; i++)
    if (s[i] != s[s.length() - i - 1]) {
      cout << s.length();
      return 0;
    }
  for (int i = 0; i < s.length() / 2; i++)
    if (s[i] != s[i + 1]) {
      cout << s.length() - 1;
      return 0;
    }
  cout << 0;
  return 0;
}
