#include <bits/stdc++.h>
using namespace std;
bool ispalindrome(string s) {
  int n = s.length();
  if (n == 1) return true;
  for (int i = 0; i < n / 2; i++) {
    if (s[i] != s[n - i - 1]) return false;
  }
  return true;
}
int main() {
  string s;
  cin >> s;
  int n = s.length();
  int k = n;
  string t = s;
  if (!ispalindrome(t)) {
    cout << t.length();
    return 0;
  }
  for (int i = 0; i < k / 2; i++) {
    t = s;
    t.erase(t.begin());
    if (!ispalindrome(t)) {
      cout << t.length();
      return 0;
    }
    t = s;
    t.erase(t.begin() + n - 2);
    if (!ispalindrome(t)) {
      cout << t.length();
      return 0;
    }
    s.erase(s.begin());
    s.erase(s.begin() + n - 2);
    n -= 2;
    if (n < 0 || s == "") {
      cout << 0;
      return 0;
    }
  }
  if (s.length() == 1) cout << 0;
  return 0;
}
