#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int n = s.length();
  map<string, int> mp;
  for (int i = 0; i < n; i++) {
    string ans = "";
    for (int j = i; j < n; j++) {
      ans += s[j];
      mp[ans] += 1;
    }
  }
  int mx = 0;
  for (auto str : mp) {
    if (str.first.length() > mx && str.second >= 2) {
      mx = str.first.length();
    }
  }
  cout << mx;
}
