n = int(input())
S = input()
ans = 0
for d in range(n):
    cnt = 0
    for i in range(n-d):
        if S[i] == S[d+i]:
            cnt += 1
        else:
            cnt = 0
        ans = max(ans, min(cnt, d))
print(ans) n = int(input()) n int(input()) int input() input S = input() S input() input ans = 0 ans 0 for d in range(n):
    cnt = 0
    for i in range(n-d):
        if S[i] == S[d+i]:
            cnt += 1
        else:
            cnt = 0
        ans = max(ans, min(cnt, d)) d range(n) range n cnt = 0 cnt 0 for i in range(n-d):
        if S[i] == S[d+i]:
            cnt += 1
        else:
            cnt = 0
        ans = max(ans, min(cnt, d)) i range(n-d) range n-d n d if S[i] == S[d+i]:
            cnt += 1
        else:
            cnt = 0
         S[i] == S[d+i] S[i] S i S[d+i] S d+i d i cnt += 1 cnt 1 cnt = 0 cnt 0 ans = max(ans, min(cnt, d)) ans max(ans, min(cnt, d)) max ans min(cnt, d) min cnt d print(ans) print ans ans = 0 0 ans cnt += 1 1 cnt cnt = 0 0 cnt cnt = 0 0 cnt n = int(input()) int(input()) n S = input() input() S ans = max(ans, min(cnt, d)) max(ans, min(cnt, d)) ans
n = int(input())
S = input()
ans = 0
for d in range(n):
    cnt = 0
    for i in range(n-d):
        if S[i] == S[d+i]:
            cnt += 1
        else:
            cnt = 0
        ans = max(ans, min(cnt, d))
print(ans)
