#include <bits/stdc++.h>
using namespace std;
int main() {
  int res = 0;
  string s;
  cin >> s;
  for (int i = 0; i < s.length(); ++i) {
    for (int j = 1; j <= s.length(); ++j) {
      string b = s.substr(i, j);
      for (int k = i + 1; k < s.length(); ++k) {
        if (s.substr(k, j) == b && j > res) res = j;
      }
    }
  }
  cout << res << endl;
  return 0;
}
