#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int b = s.length();
  int i, j, k, m = 0;
  for (i = 0; i < b; ++i) {
    for (j = i + 1; j < b; ++j) {
      k = 0;
      while (s[i + k] == s[j + k]) k++;
      m = max(m, k);
    }
  }
  printf("%d\n", m);
  return 0;
}
