#include <bits/stdc++.h>
using namespace std;
string str, s;
int i, j, len, ans;
int main() {
  cin >> str;
  len = str.length();
  for (ans = len - 1; ans > 0; --ans) {
    for (j = 0; str[j] != '\0'; ++j) {
      if (j + ans >= len) break;
      s.clear();
      for (i = 0; i < ans; ++i) s += str[j + i];
      if (str.find(s, j + 1) != string::npos) {
        cout << ans << endl;
        return 0;
      }
    }
  }
  cout << "0" << endl;
  return 0;
}
