#include <bits/stdc++.h>
using namespace std;
string pega_pedaco_string(string& ada, int x, int y) {
  string copy;
  if (x < ada.size() && y < ada.size())
    while (x <= y) copy += ada[x++];
  return copy;
}
int quant_subs(string& n, string& alvo) {
  int dep = -1, indice = -1, con = 0;
  while ((indice = n.find(alvo, ++dep)) && (indice >= 0) ||
         (indice < (n).size())) {
    con++;
    dep = indice;
  }
  return con;
}
int main() {
  string n;
  while (cin >> n) {
    int t = 0;
    for (int k = 0; k < (n).size(); k++) {
      for (int i = 0; i < (n).size(); i++) {
        string s = pega_pedaco_string(n, i, i + k);
        int temp = quant_subs(n, s);
        if ((s).size() > 0 && temp > 1) {
          int x = (s).size();
          t = max(t, x);
        }
      }
    }
    cout << t << endl;
  }
  return 0;
}
