#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e2 + 20;
int a[maxn];
int main() {
  int n;
  string a;
  cin >> a;
  n = (int)a.size();
  int sum = 0;
  int jav = 0;
  bool c = true;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      int k = 0;
      while (a[i + k] == a[j + k]) {
        k++;
        jav = max(jav, k);
      }
    }
  }
  cout << jav;
  return 0;
}
