#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, l, k;
  char s[52];
  cin >> s;
  l = strlen(s);
  if (l == 1) {
    cout << 0;
    return 0;
  }
  if (l == 2) {
    if (s[0] == s[1]) {
      cout << 0;
      return 0;
    } else {
      cout << 2;
      return 0;
    }
  }
  if (s[0] != s[l - 1]) {
    cout << l;
    return 0;
  }
  k = 0;
  for (i = 1; i <= (l / 2) - 1; i++) {
    if (s[i] != s[l - i - 1]) {
      cout << l;
      return 0;
    } else {
      if (s[i] != s[i - 1] && k == 0) {
        k = 1;
      }
    }
  }
  if (k == 1)
    cout << l - 1;
  else {
    if (l % 2 == 0)
      cout << 0;
    else {
      if (s[(l / 2)] == s[(l / 2) - 1])
        cout << 0;
      else
        cout << l - 1;
    }
  }
  return 0;
}
