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

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

print(ans)