#include <bits/stdc++.h>
using namespace std;
map<string, int> M;
int main() {
  string s;
  cin >> s;
  int l = s.length();
  int r = 0;
  for (int i = 0; i < l; i++) {
    string t = "";
    for (int j = i; j < l; j++) {
      t += s[j];
      if (M.count(t))
        M[t]++;
      else
        M[t] = 1;
      if (M[t] >= 2) r = max(r, (int)t.length());
    }
  }
  cout << r << endl;
}
