#include <bits/stdc++.h>
using namespace std;
int main() {
  char str[100 + 10 + 1];
  int cnt;
  int max;
  while (cin >> str) {
    max = 0;
    int len = strlen(str);
    for (int i = 0; i < len; i++) {
      for (int j = i + 1; j < len; j++) {
        if (str[i] == str[j]) {
          cnt = 0;
          for (int uuu = 0; uuu + i <= len && uuu + j <= len; uuu++) {
            if (str[i + uuu] == str[j + uuu]) {
              cnt++;
              if (cnt >= max) max = cnt;
            } else
              break;
          }
        }
      }
    }
    cout << max << endl;
  }
  return 0;
}
