#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, z, len = 0, mx = 0, x, y;
  string s;
  cin >> s;
  z = s.size();
  for (i = 0; i < z; i++) {
    x = i;
    for (j = i + 1; j < z; j++) {
      if (s[i] == s[j]) {
        y = j;
        len = 0;
        while (s[x + len] == s[y + len]) {
          ++len;
          mx = max(mx, len);
        }
      }
    }
  }
  cout << mx << endl;
  return 0;
}
