#include <bits/stdc++.h>
using namespace std;
const unsigned long long prime = 29;
const int MAX = 110000;
string a;
char buff[MAX];
unsigned long long primes[MAX];
unsigned long long hashes[MAX];
int l;
unsigned long long genHash(int p, int k) {
  if (p == 0) return hashes[k] * primes[l];
  return (hashes[k] - hashes[p - 1]) * primes[a.size() - p];
}
bool check(int s) {
  set<unsigned long long> S;
  for (int i = 0; i <= l - s; i++) {
    unsigned long long temp = genHash(i, i + s - 1);
    if (S.find(temp) != S.end()) return 1;
    S.insert(temp);
  }
  return 0;
}
void bs() {
  int p = 0;
  int q = l;
  while (p != q) {
    int s = (p + q) / 2;
    if (check(s))
      p = s + 1;
    else
      q = s;
  }
  printf("%d", p - 1);
}
void init() {
  primes[0] = 1;
  for (int i = 1; i <= l; i++) primes[i] = primes[i - 1] * prime;
  hashes[0] = (int)a[0];
  for (int i = 1; i < l; i++) hashes[i] = hashes[i - 1] + (int)a[i] * primes[i];
}
int main() {
  scanf("%s", buff);
  a = buff;
  l = a.size();
  init();
  bs();
  return 0;
}
