#include <bits/stdc++.h>
using namespace std;
string s;
int i, j, p, maxx, nr, n;
int main() {
  cin >> s;
  n = s.size() - 1;
  for (p = 1; p <= n; p++) {
    i = 0;
    j = p;
    nr = 0;
    while (j <= n) {
      while (s[i] != s[j] && j <= n) {
        j++;
        i++;
      }
      while (s[i] == s[j] && j <= n) {
        i++;
        j++;
        nr++;
      }
      if (nr > maxx) maxx = nr;
      nr = 0;
    }
  }
  cout << maxx;
}
