#include <bits/stdc++.h>
using namespace std;
vector<string> SubstringGenerate(string str);
int main() {
  string str;
  vector<string> store;
  int i, j;
  int answer = 0;
  while (cin >> str) {
    answer = 0;
    store = SubstringGenerate(str);
    for (i = 0; i < store.size(); i++) {
      for (j = 0; j < store.size(); ++j) {
        if (i != j) {
          if (store[i] == store[j] && store[i].size() > answer)
            answer = store[i].size();
        }
      }
    }
    cout << answer << endl;
  }
}
vector<string> SubstringGenerate(string str) {
  int i, j, len;
  vector<string> store;
  len = str.size();
  for (i = 0; i < len; i++) {
    for (j = i; j < len; j++) store.push_back(str.substr(i, j - i + 1));
  }
  return store;
}
