#include <bits/stdc++.h>
using namespace std;
int main() {
  char l[200];
  cin >> l;
  int len = strlen(l);
  int a[len + 1][len + 1];
  if (len == 1)
    cout << 0;
  else {
    for (int i = 0; i <= len; i++) a[0][i] = a[i][0] = 0;
    int max_v = 0;
    for (int i = 1; i <= len; i++) {
      for (int j = 1; j <= len; j++) {
        if (i != j && l[i - 1] == l[j - 1])
          a[i][j] = a[i - 1][j - 1] + 1;
        else
          a[i][j] = 0;
        max_v = max(max_v, a[i][j]);
      }
    }
    cout << max_v << endl;
  }
  return 0;
}
