#include <bits/stdc++.h>
int main() {
  std::string s;
  std::cin >> s;
  for (int len = s.size(); len; --len)
    for (int i = 0; i + len < s.size(); ++i)
      if (s.find(s.substr(i, len), i + 1) != -1)
        return std::cout << len << '\n', 0;
  std::cout << "0\n";
}
