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