CF BUDDY
← Problems·

23A · You're Given a String...

1200 · brute force, greedy

Problem: You're given a string of lower-case Latin letters. Your task is to find the length of its longest substring that can be met in the string at least twice. These occurrences can overlap (see sample test 2).

Input Format: The first input line contains the string. It's guaranteed, that the string is non-empty, consists of lower-case Latin letters, and its length doesn't exceed 100.

Output Format: Output one number — length of the longest substring that can be met in the string at least twice.

Sample Cases

Case 1

Input

abcd

Output

0

Case 2

Input

ababa

Output

3

Case 3

Input

zzz

Output

2

Similar problems

00:00:00
Loading editor…
Welcome! I'm your coding tutor for this problem. Use the chips below to reveal stored hints or get AI feedback on your code. I'll guide you step by step — never giving away the solution.

Sign in to unlock AI tutor feedback