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).
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.
def count_substrings(string, substring):
    count = 0
    start_index = 0

    while True:
        start_index = string.find(substring, start_index) + 1  # search from the start index add one to look next time from the next symbol

        if start_index > 0:  # -1 + 1 = 0 => substring not found
            count += 1
        else:
            return count


string = input()
max_reps = 0
max_length = 0

answer = ""
for i in range(0, len(string) - 1):
    for j in range(i + 1, len(string)):
        current_reps = count_substrings(string, string[i:j])
        current_length = len(string[i:j])
        if current_reps > 1 and current_reps > max_reps and current_length > 1 or (current_reps == max_reps and current_length > max_length):
            max_reps = current_reps
            max_length = current_length
            answer = string[i:j]

# print(max_reps)
print(len(answer))
# print(answer)

