n=int(input())
s=input()
dp=[[0]*(n+1) for i in range(n+1)]
for i in range(n-1,-1,-1):
    for j in range(n-1,i,-1):
        if s[j]==s[i] and dp[i+1][j+1]+1<=j-i:
            dp[i][j]=dp[i+1][j+1]+1
ans=0
for i in range(n):
    for j in range(n):
        ans=max(ans,dp[i][j])
print(ans) n=int(input()) n int(input()) int input() input s=input() s input() input [0]*(n+1) for i in range(n+1) for i in range(n+1) i range(n+1) range n+1 n 1 for i in range(n+1) [0]*(n+1) [0] 0 n+1 n 1 dp=[[0]*(n+1) for i in range(n+1)] dp [[0]*(n+1) for i in range(n+1)] for i in range(n-1,-1,-1):
    for j in range(n-1,i,-1):
        if s[j]==s[i] and dp[i+1][j+1]+1<=j-i:
            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,i,-1):
        if s[j]==s[i] and dp[i+1][j+1]+1<=j-i:
            dp[i][j]=dp[i+1][j+1]+1 j range(n-1,i,-1) range n-1 n 1 i -1 if s[j]==s[i] and dp[i+1][j+1]+1<=j-i:
            dp[i][j]=dp[i+1][j+1]+1 s[j]==s[i] and dp[i+1][j+1]+1<=j-i s[j]==s[i] s[j] s j s[i] s i dp[i+1][j+1]+1<=j-i 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 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(n):
        ans=max(ans,dp[i][j]) i range(n) range n for j in range(n):
        ans=max(ans,dp[i][j]) j range(n) range n 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 dp=[[0]*(n+1) for i in range(n+1)] [[0]*(n+1) for i in range(n+1)] dp ans=max(ans,dp[i][j]) max(ans,dp[i][j]) ans n=int(input()) int(input()) n ans=0 0 ans s=input() input() s
n=int(input())
s=input()
dp=[[0]*(n+1) for i in range(n+1)]
for i in range(n-1,-1,-1):
    for j in range(n-1,i,-1):
        if s[j]==s[i] and dp[i+1][j+1]+1<=j-i:
            dp[i][j]=dp[i+1][j+1]+1
ans=0
for i in range(n):
    for j in range(n):
        ans=max(ans,dp[i][j])
print(ans)