#include <bits/stdc++.h>
using namespace std;
int main() {
  char s[51];
  cin >> s;
  int l = strlen(s);
  int i, j, count = 0, temp = 0;
  for (i = 0, j = l - 1; i < l / 2; i++, j--) {
    if (s[i] == s[j])
      count++;
    else
      break;
  }
  if (count != l / 2) {
    cout << l << endl;
    return 0;
  } else {
    for (i = 0; i < l - 1; i++) {
      if (s[i] != s[i + 1]) {
        temp = 1;
        break;
      }
    }
    if (temp == 0) {
      cout << "0" << endl;
      return 0;
    } else
      cout << l - 1 << endl;
  }
}
