#include <bits/stdc++.h>
using namespace std;
int A[5005];
int N, M, a, b, isiz, ssiz, ans, giri;
void manachers(string s) {
  int ssiz = s.size();
  int R = 0, P = 0;
  for (int i = 0; i < ssiz; i++) {
    if (i <= R)
      A[i] = min(A[2 * P - i], R - i);
    else
      A[i] = 0;
    while (i - A[i] - 1 >= 0 && i + A[i] + 1 < ssiz &&
           s[i - A[i] - 1] == s[i + A[i] + 1])
      A[i]++;
    if (i + A[i] > R) R = i + A[i], P = i;
  }
}
int main(void) {
  string imsi, str;
  cin >> imsi;
  isiz = imsi.size();
  for (int i = 0; i < isiz; i++) {
    str.push_back(-1);
    str += imsi[i];
  }
  str.push_back(-1);
  manachers(str);
  ssiz = str.size();
  for (int i = 1; i <= isiz; i++)
    for (int j = i; j <= isiz; j++) {
      a = i;
      b = j;
      giri = b - a + 1;
      a = a * 2;
      b = b * 2;
      int mid = (a + b) >> 1;
      int rad = (b - a) >> 1;
      if (A[mid - 1] < rad) ans = max(ans, giri);
    }
  printf("%d", ans);
}
