#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int b = 0;
  string a;
  int m = 0;
  for (int i = 0; i < s.size(); i++)
    for (int j = s.size() - 1; j >= 0; j--) {
      a = s.substr(i, j);
      int c1 = s.find(a);
      int c2 = s.rfind(a);
      if (c1 != c2 && a.size() > m) m = a.size();
    }
  cout << m << endl;
}
