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