#include <bits/stdc++.h>
using namespace std;
template <class T>
T sqr(T a) {
  return a * a;
}
#pragma comment(linker, "/STACK:16777216")
int n;
char s[105];
string str;
int main() {
  gets(s);
  str = s;
  n = strlen(s);
  for (int i = n - 1; i > 0; --i)
    for (int j = 0; j <= n - i; ++j)
      for (int k = j + 1; k <= n - i; ++k)
        if (str.substr(j, i) == str.substr(k, i)) {
          printf("%d", i);
          return 0;
        }
  printf("0");
  return 0;
}
