#include <bits/stdc++.h>
using namespace std;
string a[102400];
int main() {
  string s;
  cin >> s;
  int n = s.size(), cnt = 0, max = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 1; i + j <= n; j++) {
      cnt++;
      a[cnt] = s.substr(i, j);
    }
  }
  for (int i = 1; i <= cnt; i++) {
    for (int j = 2; j <= cnt; j++) {
      if (a[i] == a[j] && i != j && a[i].size() > max) {
        max = a[i].size();
      }
    }
  }
  cout << max;
  return 0;
}
