#include <bits/stdc++.h>
using namespace std;
bool zfuc(string s, int a) {
  int n = s.size();
  vector<int> z(n);
  int l, r, d = 0;
  for (int i = 1, l = 0, r = 0; i < n; i++) {
    if (i <= r) z[i] = min(r - i + 1, z[i - l]);
    while (i + z[i] < n && s[z[i]] == s[z[i] + i]) z[i]++;
    if (i + z[i] - 1 > r) l = i, r = i + z[i] - 1;
    if (z[i] >= a && d == 1) return 1;
    if (z[i] >= a && d == 0) d = 1;
  }
  return 0;
}
int n, i, j, m, c;
string s, t, e;
int main() {
  cin >> s;
  n = s.size();
  for (i = 0; i < n; i++) {
    for (j = 1; j + i <= n; j++) {
      t = s.substr(i, j).c_str();
      e = t + 'A';
      e = e + s;
      c = zfuc(e, j);
      if (c == 1 && j > m) {
        m = j;
      }
    }
  }
  cout << m;
  return 0;
}
