#include <bits/stdc++.h>
const long long max9 = 10 + 1e9, max6 = 10 + 1e6, max12 = 10 + 1e12,
                max15 = 10 + 1e15;
const long long min6 = -1 * max6, min9 = -1 * max9, min12 = -1 * max12,
                min15 = -1 * max15;
const long long R = 7 + 1e9, NN = 10 + 1e5;
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  cin >> s;
  bool NO = false;
  int i, j;
  i = 0;
  j = s.size() - 1;
  for (i = 0, j = s.size() - 1; i <= j; i++, j--) {
    if (s[i] != s[j]) NO = true;
  }
  if (!NO) {
    for (i = 0; i < s.size() - 1; i++)
      if (s[i] != s[i + 1]) break;
    if (i == s.size() - 1)
      cout << 0;
    else
      cout << s.size() - 1;
  } else
    cout << s.size();
  return 0;
}
