#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  while (cin >> s) {
    int N = s.size();
    int l = N - 1;
    for (; l > 0; --l) {
      for (int i = 0; i + l <= N; ++i) {
        string sub = s.substr(i, l);
        size_t head = s.find(sub);
        if (head != string::npos) {
          size_t tail = s.find(sub, head + 1);
          if (tail != string::npos) {
            goto END;
          }
        }
      }
    }
  END:;
    cout << l << endl;
  }
  return 0;
}
