#include <bits/stdc++.h>
using namespace std;
int N, M, T;
int main() {
  int i, j, k;
  string s, pat, x;
  size_t pos;
  cin >> s;
  N = s.size();
  bool ok = false;
  for (i = N - 1; i >= 1; i--) {
    for (j = 0; j + i <= N; j++) {
      pat = s.substr(j, i);
      x = s.substr(j + 1);
      pos = x.find(pat);
      if ((int)pos >= 0) {
        ok = true;
        break;
      }
    }
    if (ok) break;
  }
  printf("%d\n", i);
  scanf(" ");
}
