N = int(input())
S = input()

dp = [[0] * N for _ in range(N)]

for j in range(N):
    if S[j] == S[-1]:
        dp[-1][j] = 1

for i in range(N - 2, -1, -1):
    for j in range(N - 1):
        if S[i] == S[j]:
            dp[i][j] = dp[i + 1][j + 1] + 1
    if S[i] == S[-1]:
        dp[i][-1] = 1

ans = 0
for i in range(N):
    for j in range(N):
        ans = max(ans, min(dp[i][j], abs(i - j)))

print(ans) N = int(input()) N int(input()) int input() input S = input() S input() input [0] * N for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) [0] * N [0] 0 N dp = [[0] * N for _ in range(N)] dp [[0] * N for _ in range(N)] for j in range(N):
    if S[j] == S[-1]:
        dp[-1][j] = 1 j range(N) range N if S[j] == S[-1]:
        dp[-1][j] = 1 S[j] == S[-1] S[j] S j S[-1] S -1 dp[-1][j] = 1 dp[-1][j] [-1] dp -1 j 1 for i in range(N - 2, -1, -1):
    for j in range(N - 1):
        if S[i] == S[j]:
            dp[i][j] = dp[i + 1][j + 1] + 1
    if S[i] == S[-1]:
        dp[i][-1] = 1 i range(N - 2, -1, -1) range N - 2 N 2 -1 -1 for j in range(N - 1):
        if S[i] == S[j]:
            dp[i][j] = dp[i + 1][j + 1] + 1
     j range(N - 1) range N - 1 N 1 if S[i] == S[j]:
            dp[i][j] = dp[i + 1][j + 1] + 1
     S[i] == S[j] S[i] S i S[j] S j dp[i][j] = dp[i + 1][j + 1] + 1 dp[i][j] [i] dp i j dp[i + 1][j + 1] + 1 dp[i + 1][j + 1] [i + 1] dp i + 1 i 1 j + 1 j 1 1 if S[i] == S[-1]:
        dp[i][-1] = 1 S[i] == S[-1] S[i] S i S[-1] S -1 dp[i][-1] = 1 dp[i][-1] [i] dp i -1 1 ans = 0 ans 0 for i in range(N):
    for j in range(N):
        ans = max(ans, min(dp[i][j], abs(i - j))) i range(N) range N for j in range(N):
        ans = max(ans, min(dp[i][j], abs(i - j))) j range(N) range N ans = max(ans, min(dp[i][j], abs(i - j))) ans max(ans, min(dp[i][j], abs(i - j))) max ans min(dp[i][j], abs(i - j)) min dp[i][j] [i] dp i j abs(i - j) abs i - j i j print(ans) print ans S = input() input() S ans = max(ans, min(dp[i][j], abs(i - j))) max(ans, min(dp[i][j], abs(i - j))) ans dp = [[0] * N for _ in range(N)] [[0] * N for _ in range(N)] dp ans = 0 0 ans N = int(input()) int(input()) N
N = int(input())
S = input()

dp = [[0] * N for _ in range(N)]

for j in range(N):
    if S[j] == S[-1]:
        dp[-1][j] = 1

for i in range(N - 2, -1, -1):
    for j in range(N - 1):
        if S[i] == S[j]:
            dp[i][j] = dp[i + 1][j + 1] + 1
    if S[i] == S[-1]:
        dp[i][-1] = 1

ans = 0
for i in range(N):
    for j in range(N):
        ans = max(ans, min(dp[i][j], abs(i - j)))

print(ans)
