n=int(input())
s=input()
mx=0
for i in range(1,n):
  c=0
  for j in range(n-i):
    if s[j]==s[j+i]:
      c+=1
      mx=max(mx,c)
      if c==i:
        break
    else:
      c=0
print(mx) n=int(input()) n int(input()) int input() input s=input() s input() input mx=0 mx 0 for i in range(1,n):
  c=0
  for j in range(n-i):
    if s[j]==s[j+i]:
      c+=1
      mx=max(mx,c)
      if c==i:
        break
    else:
      c=0 i range(1,n) range 1 n c=0 c 0 for j in range(n-i):
    if s[j]==s[j+i]:
      c+=1
      mx=max(mx,c)
      if c==i:
        break
    else:
      c=0 j range(n-i) range n-i n i if s[j]==s[j+i]:
      c+=1
      mx=max(mx,c)
      if c==i:
        break
    else:
      c=0 s[j]==s[j+i] s[j] s j s[j+i] s j+i j i c+=1 c 1 mx=max(mx,c) mx max(mx,c) max mx c if c==i:
        break
     c==i c i break c=0 c 0 print(mx) print mx mx=max(mx,c) max(mx,c) mx s=input() input() s mx=0 0 mx c=0 0 c c+=1 1 c n=int(input()) int(input()) n c=0 0 c
n=int(input())
s=input()
mx=0
for i in range(1,n):
  c=0
  for j in range(n-i):
    if s[j]==s[j+i]:
      c+=1
      mx=max(mx,c)
      if c==i:
        break
    else:
      c=0
print(mx)
