#include <bits/stdc++.h>
using namespace std;
string s;
int len;
int ans, tmp;
void input() { cin >> s; }
void solve() {
  len = s.length();
  for (int i = 0; i < len; i++) {
    for (int j = i + 1; j < len; j++) {
      tmp = 0;
      while (s[i + tmp] == s[j + tmp]) tmp++;
      if (tmp > ans) ans = tmp;
    }
  }
  cout << ans << "\n";
}
int main() {
  input();
  solve();
  return 0;
}
