Time limit
0.5s
Memory limit
128 MB
Developer Cubelover created Cubelang, a helper language for writing programs in Whitespace. While using Cubelang, a new text editor better suited to the language became necessary. After a long effort, the editor was completed and named Cubeditor.
A usual text editor reports a search string even if it appears only once. Cubelang needs a different feature: within a given string, it should find only substrings that appear at least twice. The two occurrences may overlap.
For instance, in abcdabc, abc appears twice and can be found, while abcd appears only once and cannot be found.
There may be many substrings that appear at least twice. Given a string, find the length of the longest such substring.
For instance, in abcabcabc, abc appears three times and abcabc appears twice. However, abcabca appears only once. Therefore the longest substring satisfying the condition is abcabc, whose length is 6.
The first line contains a string. Its length is at most 5,000, and every character is a lowercase English letter.
Print the maximum length among substrings of the input string that appear at least twice. If no non-empty substring appears at least twice, print 0.