#include <bits/stdc++.h>
using namespace std;
long long N = 2e5 + 5;
std::vector<int> v;
const int maxn = 1e5 + 5;
int t[maxn], l[maxn];
bool isVowel(char a) {
  if (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u') return true;
  return false;
}
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
  return x * f;
}
long long INF = 1e9;
int n;
vector<int> ans;
void solve() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  string t = s;
  reverse(t.begin(), t.end());
  if (s != t) {
    cout << (int)s.length() << '\n';
    return;
  }
  if (s == string(s.length(), s[0])) {
    cout << 0 << '\n';
    return;
  }
  cout << (int)s.length() - 1 << '\n';
}
int main() {
  ios_base::sync_with_stdio(0);
  solve();
}
