#include <bits/stdc++.h>
using namespace std;
string line;
bool isequal(int a, int b, int len) {
  for (int i = 0; i < len; i++) {
    if (line[a + i] != line[b + i]) {
      return false;
    }
  }
  return true;
}
int main() {
  cin >> line;
  for (int len = line.length() - 1; len >= 1; len--) {
    for (int a = 0; a <= line.length() - len; a++) {
      for (int b = a + 1; b <= line.length() - len; b++) {
        if (isequal(a, b, len)) {
          cout << len << endl;
          return 0;
        }
      }
    }
  }
  cout << 0 << endl;
  return 0;
}
