#include <bits/stdc++.h>
using namespace std;
int longestSubstring(string s) {
  int i, j;
  int l = s.length();
  int maxi = 0;
  map<string, int> mpp;
  for (i = 0; i < l; i++) {
    string temp = "";
    for (j = i; j < l; j++) {
      temp += s[j];
      mpp[temp]++;
      maxi = max(maxi, mpp[temp]);
    }
  }
  auto it = mpp.begin();
  int len = 0;
  string ans = "";
  while (it != mpp.end()) {
    if (it->second >= 2) {
      string temp = it->first;
      if (temp.length() > len) {
        ans = temp;
        len = temp.length();
      } else if (temp.length() == len) {
        if (temp < ans) ans = temp;
      }
    }
    it++;
  }
  return len;
}
int main() {
  string s;
  cin >> s;
  int ans = longestSubstring(s);
  cout << ans;
}
