n = int(input())
s = input()

l = len(s)

dp = [[0] * (l + 1) for _ in range(l + 1)]
dp[0][0] = 1

ans = 0
for i, ei in enumerate(s, 1):
    for j, ej in enumerate(s[i:], i+1):
        if ei == ej:
            dp[i][j] = min(dp[i-1][j-1] + 1, j - i)
            ans = max(ans, dp[i][j])

print(ans) n = int(input()) n int(input()) int input() input s = input() s input() input l = len(s) l len(s) len s [0] * (l + 1) for _ in range(l + 1) for _ in range(l + 1) _ range(l + 1) range l + 1 l 1 for _ in range(l + 1) [0] * (l + 1) [0] 0 l + 1 l 1 dp = [[0] * (l + 1) for _ in range(l + 1)] dp [[0] * (l + 1) for _ in range(l + 1)] dp[0][0] = 1 dp[0][0] [0] dp 0 0 1 ans = 0 ans 0 for i, ei in enumerate(s, 1):
    for j, ej in enumerate(s[i:], i+1):
        if ei == ej:
            dp[i][j] = min(dp[i-1][j-1] + 1, j - i)
            ans = max(ans, dp[i][j]) i ei enumerate(s, 1) enumerate s 1 for j, ej in enumerate(s[i:], i+1):
        if ei == ej:
            dp[i][j] = min(dp[i-1][j-1] + 1, j - i)
            ans = max(ans, dp[i][j]) j ej enumerate(s[i:], i+1) enumerate s[i:] s i: i i+1 i 1 if ei == ej:
            dp[i][j] = min(dp[i-1][j-1] + 1, j - i)
            ans = max(ans, dp[i][j]) ei == ej ei ej dp[i][j] = min(dp[i-1][j-1] + 1, j - i) dp[i][j] [i] dp i j min(dp[i-1][j-1] + 1, j - i) min dp[i-1][j-1] + 1 dp[i-1][j-1] [i-1] dp i-1 i 1 j-1 j 1 1 j - i j i ans = max(ans, dp[i][j]) ans max(ans, dp[i][j]) max ans dp[i][j] [i] dp i j print(ans) print ans ans = max(ans, dp[i][j]) max(ans, dp[i][j]) ans n = int(input()) int(input()) n dp = [[0] * (l + 1) for _ in range(l + 1)] [[0] * (l + 1) for _ in range(l + 1)] dp ans = 0 0 ans l = len(s) len(s) l s = input() input() s
n = int(input())
s = input()

l = len(s)

dp = [[0] * (l + 1) for _ in range(l + 1)]
dp[0][0] = 1

ans = 0
for i, ei in enumerate(s, 1):
    for j, ej in enumerate(s[i:], i+1):
        if ei == ej:
            dp[i][j] = min(dp[i-1][j-1] + 1, j - i)
            ans = max(ans, dp[i][j])

print(ans)
