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