#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int n = s.length();
  int i;
  int mx = 0;
  for (i = 0; i < n; i++) {
    string x = s;
    for (int j = n; j >= 0; j--) {
      string ss = s.substr(i, j - i);
      x[i] = '#';
      if (x.find(ss) != string::npos) {
        int l = ss.length();
        mx = max(mx, l);
      }
    }
  }
  cout << mx;
}
