#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int ans = 0;
  cin >> s;
  for (int k = 0; k < s.size(); ++k) {
    for (int j = 1; j < s.size(); ++j) {
      string totry = s.substr(k, j);
      int sz = totry.size();
      int idx = 0;
      int ct = 0;
      while (idx < s.size() && s.find(totry, idx) != string::npos) {
        idx = s.find(totry, idx) + 1;
        ++ct;
      }
      if (ct >= 2) ans = max(ans, sz);
    }
  }
  cout << ans;
}
