#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, cont = 0, ans = 0;
  string s;
  cin >> s;
  int len = s.size();
  for (i = 0; i < len - 1; i++) {
    for (j = i + 1; j < len; j++) {
      cont = 0;
      int k = i, l = j;
      while (s[k] == s[l] && l < len) {
        cont++;
        k++;
        l++;
      }
      if (cont > ans) ans = cont;
    }
  }
  cout << ans << endl;
  return 0;
}
