#include <bits/stdc++.h>
using namespace std;
int main() {
  bool t = false, k = false;
  char a[50];
  int n, j;
  cin >> a;
  n = strlen(a);
  j = n - 1;
  for (int i = 0; i < n - 1; i++)
    if (a[i] != a[i + 1]) {
      k = true;
      break;
    }
  for (int i = 0; i < n / 2; i++)
    if (a[i] != a[j]) {
      t = true;
      break;
    } else
      j--;
  if (!k)
    cout << 0;
  else if (!t)
    cout << n - 1;
  else
    cout << n;
}
