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

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

ans = 0
for i in range(N):
    for j in range(N):
        ans = max(ans, min(dp[i][j], j-i))
print(ans) N = int(input()) N int(input()) int input() input S = input() S input() input [0 for _ in range(N+1)] for _ in range(N+1) for _ in range(N+1) _ range(N+1) range N+1 N 1 for _ in range(N+1) [0 for _ in range(N+1)] dp = [[0 for _ in range(N+1)] for _ in range(N+1)] dp [[0 for _ in range(N+1)] for _ in range(N+1)] for i in range(N-1, -1, -1):
    for j in range(N-1, -1, -1):
        if S[i] == S[j]:
            dp[i][j] = dp[i+1][j+1] + 1
        else:
            dp[i][j] = 0 i range(N-1, -1, -1) range N-1 N 1 -1 -1 for j in range(N-1, -1, -1):
        if S[i] == S[j]:
            dp[i][j] = dp[i+1][j+1] + 1
        else:
            dp[i][j] = 0 j range(N-1, -1, -1) range N-1 N 1 -1 -1 if S[i] == S[j]:
            dp[i][j] = dp[i+1][j+1] + 1
        else:
            dp[i][j] = 0 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 dp[i][j] = 0 dp[i][j] [i] dp i j 0 ans = 0 ans 0 for i in range(N):
    for j in range(N):
        ans = max(ans, min(dp[i][j], j-i)) i range(N) range N for j in range(N):
        ans = max(ans, min(dp[i][j], j-i)) j range(N) range N ans = max(ans, min(dp[i][j], j-i)) ans max(ans, min(dp[i][j], j-i)) max ans min(dp[i][j], j-i) min dp[i][j] [i] dp i j j-i j i print(ans) print ans ans = max(ans, min(dp[i][j], j-i)) max(ans, min(dp[i][j], j-i)) ans S = input() input() S ans = 0 0 ans dp = [[0 for _ in range(N+1)] for _ in range(N+1)] [[0 for _ in range(N+1)] for _ in range(N+1)] dp N = int(input()) int(input()) N
N = int(input())
S = input()

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

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