#include <bits/stdc++.h>
using namespace std;
const double eps(1e-8);
int main() {
  string s;
  while (cin >> s) {
    int ls = s.length();
    int max1 = 0;
    for (int i = 0; i < ls; i++) {
      for (int j = i + 1; j < ls; j++) {
        int m = 0;
        while (s[i + m] == s[j + m]) {
          m++;
        }
        max1 = max(m, max1);
      }
    }
    cout << max1 << endl;
  }
  return 0;
}
