#include <bits/stdc++.h>
using namespace std;
const int N = int(1e5) + 1;
const int mod = int(1e9) + 7;
int cmpfunc(const void *a, const void *b) { return *(int *)a - *(int *)b; }
int main() {
  string s;
  cin >> s;
  int flag = 1;
  int maxans = 0;
  for (int i = 0; i < s.size(); i++) {
    for (int j = 1; j <= s.size() - i; j++) {
      int ct = 0;
      string temp = s.substr(i, j);
      int npos = s.find(temp, 0);
      while (npos != string::npos) {
        ct++;
        npos = s.find(s.substr(i, j), npos + 1);
        if (ct >= 2) {
          maxans = max(maxans, j);
          break;
        }
      }
    }
  }
  cout << maxans << endl;
  return 0;
}
