#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int flag = 0;
  cin >> s;
  int n = s.size();
  for (int i = 0; i < s.size() / 2; i++) {
    if (s[i] != s[n - i - 1]) {
      flag = 1;
    }
  }
  int count = 0;
  if (flag == 1) {
    cout << s.size();
  } else {
    char g = s[0];
    for (int i = 0; i < s.size(); i++) {
      if (s[i] == g) {
        count++;
      }
    }
    if (count == s.size()) {
      cout << 0;
    } else {
      cout << s.size() - 1;
    }
  }
}
