#include <bits/stdc++.h>
using namespace std;
bool ispel(string s) {
  long long i = s.length();
  for (long long j = 0; j < i / 2; j++) {
    if (s[j] != s[i - j - 1]) {
      return false;
    }
  }
  return true;
}
int main() {
  string s;
  cin >> s;
  long long i = s.length();
  for (long long j = 0; j < i / 2; j++) {
    if (s[j] != s[i - j - 1]) {
      cout << i << endl;
      return 0;
    }
  }
  long long freq = 0;
  for (long long j = 0; j < i; j++) {
    if (s[0] == s[j]) {
      freq++;
    } else {
      break;
    }
  }
  if (freq == i) {
    cout << "0" << endl;
    return 0;
  }
  if (ispel(s)) {
    cout << i - 1 << endl;
    return 0;
  }
}
