#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int i, j, n;
  int leng;
  int answ;
  cin >> s;
  n = s.size();
  answ = 0;
  for (i = 0; i < n; i++) {
    for (j = i + 1; j < n; j++) {
      leng = 0;
      while (s[i + leng] == s[j + leng]) leng++;
      if (leng > answ) answ = leng;
    }
  }
  cout << answ;
  return 0;
}
