#include <bits/stdc++.h>
const unsigned long long inf = 1LL << 61;
const double eps = 1e-5;
using namespace std;
bool cmp(int a, int b) { return a > b; }
vector<string> v;
int main() {
  string s;
  while (cin >> s) {
    v.clear();
    string sk = s;
    int n = s.size();
    for (int i = 0; i < n; i++) {
      string t = "";
      t += s[i];
      v.push_back(t);
    }
    for (int i = 2; i < n; i++) {
      for (int j = 0; j < n - i + 1; j++) {
        string t = "";
        for (int k = j; k < j + i; k++) {
          t += s[k];
        }
        v.push_back(t);
      }
    }
    int mark = 0;
    for (int i = v.size() - 1; i >= 0; i--) {
      int pa = s.find(v[i], 0);
      if (pa == string::npos)
        continue;
      else {
        int pb = s.find(v[i], pa + 1);
        if (pb != string::npos) {
          cout << v[i].size() << endl;
          mark = 1;
          break;
        }
      }
    }
    if (!mark) cout << 0 << endl;
  }
  return 0;
}
