#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int mx = 0;
  for (int i = 1; i <= s.length(); i++) {
    for (int j = 0; j + i <= s.length(); j++) {
      for (int k = j + 1; k + i <= s.length(); k++) {
        if (s.substr(j, i) == s.substr(k, i)) mx = i;
      }
    }
  }
  cout << mx;
}
