#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const int N = 1e7 + 9, M = 1e7, OO = 0x3f3f3f3f;
const double EPS = 1e-10, PI = acos(-1.0);
inline bool dCMP(const long double &a, const long double &b) {
  return fabsl(a - b) < EPS;
}
inline double MintoDeg(double min) { return min / 60; }
inline double to_Radian(double deg) { return deg * PI / 180.0; }
inline double to_Degree(double radian) {
  if (radian < 0) radian += 2 * PI;
  return radian * 180 / PI;
}
inline double fixAngle(double A) { return A > 1 ? 1 : (A < -1 ? -1 : A); }
struct point {
  double x, y;
  point() { x = y = 0.0; }
  point(double _x, double _y) : x(_x), y(_y) {}
  bool operator<(point other) const {
    if (fabs(x - other.x) > EPS) return x < other.x;
    return y < other.y;
  }
  bool operator==(point other) const {
    return (fabs(x - other.x) < EPS && (fabs(y - other.y) < EPS));
  }
};
string str;
string strs[N];
int main() {
  cin >> str;
  int n = str.length(), k = 0;
  for (int l = 0; l < n; ++l) {
    string s = "";
    for (int i = l; i < n; ++i) {
      s += str[i];
      strs[k++] = s;
    }
  }
  int len = 0;
  for (int i = 0; i < k; ++i) {
    int cnt = 0;
    for (int j = 0; j < k; ++j)
      if (strs[i] == strs[j]) cnt++;
    if (cnt >= 2) len = max(len, (int)strs[i].length());
  }
  printf("%d\n", len);
  return 0;
}
