#include <bits/stdc++.h>
using namespace std;
char s[110];
int i, j, maxx, n, a[110][110];
int main() {
  cin >> s;
  n = strlen(s);
  for (i = 1; i <= n; i++)
    for (j = 1; j <= n; j++) {
      if (s[i - 1] == s[j - 1] && i != j) {
        a[i][j] = a[i - 1][j - 1] + 1;
        if (a[i][j] > maxx) maxx = a[i][j];
      }
    }
  cout << maxx;
  return 0;
}
