#include <bits/stdc++.h>
using namespace std;
int main(void) {
  string s;
  cin >> s;
  int len = s.length();
  map<string, int> cnt;
  for (int i = len - 1; i > 0; i--) {
    for (int j = 0; j <= len - i; j++) {
      string sub = s.substr(j, i);
      cnt[sub]++;
      if (cnt[sub] >= 2) {
        cout << i << endl;
        return 0;
      }
    }
  }
  cout << 0 << endl;
  return 0;
}
