#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int n = s.size();
  for (int l = n; l > 0; --l) {
    for (int i = 0; i < n - l; ++i) {
      for (int j = i + 1; j <= n - l; ++j) {
        bool match = true;
        for (int k = 0; k < l; ++k) {
          if (s[i + k] != s[j + k]) {
            match = false;
            break;
          }
        }
        if (match) {
          cout << l;
          return 0;
        }
      }
    }
  }
  cout << 0;
  return 0;
}
