#include <bits/stdc++.h>
using namespace std;
int mx, cnt, k;
char s[105];
int main() {
  while (~scanf(" %s", &s)) {
    k = strlen(s);
    mx = 0;
    for (int i = 0; i < k; i++) {
      for (int j = i + 1; j < k; j++) {
        cnt = 0;
        if (s[i] == s[j]) {
          for (int o = 0; o < k; o++) {
            if (s[i + o] == s[j + o])
              cnt++;
            else
              break;
          }
        }
        if (cnt > mx) mx = cnt;
      }
    }
    printf("%d\n", mx);
  }
  return 0;
}
