N = int(input())
S = input()
 
r = 0
ans = 0
for l in range(N):
 
    while True:
        #print(S.rfind(S[l:r+1]), S[l:r+1], l, r)
 
        if S.rfind(S[l:r+1]) >= r+1:
            r += 1
            ans = max(ans, r-l)
        else:
            break
 
print(ans) N = int(input()) N int(input()) int input() input S = input() S input() input r = 0 r 0 ans = 0 ans 0 for l in range(N):
 
    while True:
        #print(S.rfind(S[l:r+1]), S[l:r+1], l, r)
 
        if S.rfind(S[l:r+1]) >= r+1:
            r += 1
            ans = max(ans, r-l)
        else:
            break
  l range(N) range N while True:
        #print(S.rfind(S[l:r+1]), S[l:r+1], l, r)
 
        if S.rfind(S[l:r+1]) >= r+1:
            r += 1
            ans = max(ans, r-l)
        else:
            break
  True if S.rfind(S[l:r+1]) >= r+1:
            r += 1
            ans = max(ans, r-l)
        else:
            break
  S.rfind(S[l:r+1]) >= r+1 S.rfind(S[l:r+1]) S.rfind S rfind S[l:r+1] S l:r+1 l r+1 r 1 r+1 r 1 r += 1 r 1 ans = max(ans, r-l) ans max(ans, r-l) max ans r-l r l break print(ans) print ans N = int(input()) int(input()) N ans = 0 0 ans r += 1 1 r r = 0 0 r ans = max(ans, r-l) max(ans, r-l) ans S = input() input() S
N = int(input())
S = input()
 
r = 0
ans = 0
for l in range(N):
 
    while True:
        #print(S.rfind(S[l:r+1]), S[l:r+1], l, r)
 
        if S.rfind(S[l:r+1]) >= r+1:
            r += 1
            ans = max(ans, r-l)
        else:
            break
 
print(ans)
