#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void init() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
ll longestNonPalSubString(string word, ll i, ll j) {
  if (i == j) return 0;
  if (word[i] != word[j])
    return j - i + 1;
  else {
    ll incI = longestNonPalSubString(word, i + 1, j);
    if (incI) return incI;
    ll decJ = longestNonPalSubString(word, i, j - 1);
    if (decJ) return decJ;
    return 0;
  }
}
int main() {
  init();
  string s;
  cin >> s;
  string t = s;
  reverse(t.begin(), t.end());
  if (count(s.begin(), s.end(), s[0]) == s.length())
    cout << 0;
  else if (s == t)
    cout << s.length() - 1;
  else
    cout << s.length();
}
