N = int(input())
S = str(input())
ans = 0
j = 0
for i in range(N):
  while j < N and S[i:j] in S[j:]:
    ans = max(ans,j-i)
    j += 1

print(ans) N = int(input()) N int(input()) int input() input S = str(input()) S str(input()) str input() input ans = 0 ans 0 j = 0 j 0 for i in range(N):
  while j < N and S[i:j] in S[j:]:
    ans = max(ans,j-i)
    j += 1 i range(N) range N while j < N and S[i:j] in S[j:]:
    ans = max(ans,j-i)
    j += 1 j < N and S[i:j] in S[j:] j < N j N S[i:j] in S[j:] S[i:j] S i:j i j S[j:] S j: j ans = max(ans,j-i) ans max(ans,j-i) max ans j-i j i j += 1 j 1 print(ans) print ans j = 0 0 j S = str(input()) str(input()) S ans = 0 0 ans j += 1 1 j N = int(input()) int(input()) N ans = max(ans,j-i) max(ans,j-i) ans
N = int(input())
S = str(input())
ans = 0
j = 0
for i in range(N):
  while j < N and S[i:j] in S[j:]:
    ans = max(ans,j-i)
    j += 1

print(ans)