#include <bits/stdc++.h>
using namespace std;
const int prime = 1009;
int main() {
  char tab[1005];
  int a, b, c, n, k, A[1005], pp[1005], prefix_sum[1005], t;
  t = 1;
  while (t--) {
    scanf("%s", tab + 1);
    n = strlen(tab + 1);
    for (int i = 1; i <= n; i++) tab[i] -= 'a';
    pp[0] = 1;
    for (int i = 1; i < n + 4; i++) pp[i] = pp[i - 1] * prime;
    a = 0;
    b = n;
    prefix_sum[0] = 0;
    for (int i = 1; i <= n; i++)
      prefix_sum[i] = prefix_sum[i - 1] + tab[i] * pp[i];
    while (a < b) {
      c = (a + b) / 2;
      for (int i = 0; i <= n - c; i++)
        A[i] = (prefix_sum[i + c] - prefix_sum[i]) * pp[(n - c) - i];
      sort(A, A + (n - c) + 1);
      bool rep = false;
      for (int i = 0; i < n - c; i++)
        if (A[i] == A[i + 1]) rep = true;
      if (rep)
        a = c + 1;
      else
        b = c;
    }
    printf("%d\n", a - 1);
  }
  return 0;
}
