#include <bits/stdc++.h>
using namespace std;
map<string, int> mp;
int main() {
  cin.sync_with_stdio(false);
  string s;
  while (cin >> s) {
    int len = s.length();
    mp.clear();
    for (int i = 0; i < len; ++i) {
      string t = "";
      for (int j = i; j < len; ++j) {
        t += s[j];
        ++mp[t];
      }
    }
    int res = 0;
    for (auto it = mp.begin(); it != mp.end(); ++it) {
      if (it->second >= 2) {
        res = max(res, (int)it->first.length());
      }
    }
    cout << res << endl;
  }
  return 0;
}
