nn = int(input())
ss = input()

ans = 0

for i in range(nn-1):
  n = nn-i
  s = ss[i:]
  a = [0]*n
  a[0] = n
  i, j = 1, 0
  while i < n:
    while i+j < n and s[j] == s[i+j]:
      j += 1
    a[i] = j
    if j == 0:
      i += 1
      continue
    k = 1
    while i+k < n and k+a[k] < j:
      a[i+k] = a[k]
      k += 1
    i += k
    j -= k
  for p in range(1, n-1):
    a[p] = min([p, a[p]])
  sub = max(a[1:])
  if ans < sub:
    ans = sub
print(ans) nn = int(input()) nn int(input()) int input() input ss = input() ss input() input ans = 0 ans 0 for i in range(nn-1):
  n = nn-i
  s = ss[i:]
  a = [0]*n
  a[0] = n
  i, j = 1, 0
  while i < n:
    while i+j < n and s[j] == s[i+j]:
      j += 1
    a[i] = j
    if j == 0:
      i += 1
      continue
    k = 1
    while i+k < n and k+a[k] < j:
      a[i+k] = a[k]
      k += 1
    i += k
    j -= k
  for p in range(1, n-1):
    a[p] = min([p, a[p]])
  sub = max(a[1:])
  if ans < sub:
    ans = sub i range(nn-1) range nn-1 nn 1 n = nn-i n nn-i nn i s = ss[i:] s ss[i:] ss i: i a = [0]*n a [0]*n [0] 0 n a[0] = n a[0] a 0 n i, j = 1, 0 i 1 j 0 while i < n:
    while i+j < n and s[j] == s[i+j]:
      j += 1
    a[i] = j
    if j == 0:
      i += 1
      continue
    k = 1
    while i+k < n and k+a[k] < j:
      a[i+k] = a[k]
      k += 1
    i += k
    j -= k
   i < n i n while i+j < n and s[j] == s[i+j]:
      j += 1
     i+j < n and s[j] == s[i+j] i+j < n i+j i j n s[j] == s[i+j] s[j] s j s[i+j] s i+j i j j += 1 j 1 a[i] = j a[i] a i j if j == 0:
      i += 1
      continue
     j == 0 j 0 i += 1 i 1 continue k = 1 k 1 while i+k < n and k+a[k] < j:
      a[i+k] = a[k]
      k += 1
     i+k < n and k+a[k] < j i+k < n i+k i k n k+a[k] < j k+a[k] k a[k] a k j a[i+k] = a[k] a[i+k] a i+k i k a[k] a k k += 1 k 1 i += k i k j -= k j k for p in range(1, n-1):
    a[p] = min([p, a[p]])
   p range(1, n-1) range 1 n-1 n 1 a[p] = min([p, a[p]]) a[p] a p min([p, a[p]]) min [p, a[p]] p a[p] a p sub = max(a[1:]) sub max(a[1:]) max a[1:] a 1: 1 if ans < sub:
    ans = sub ans < sub ans sub ans = sub ans sub print(ans) print ans nn = int(input()) int(input()) nn ans = sub sub ans s = ss[i:] ss[i:] s k += 1 1 k k = 1 1 k i += k k i ans = 0 0 ans j -= k k j j += 1 1 j a = [0]*n [0]*n a ss = input() input() ss i += 1 1 i sub = max(a[1:]) max(a[1:]) sub i, j = 1, 0 1 i j = 1, 0 0 j n = nn-i nn-i n
nn = int(input())
ss = input()

ans = 0

for i in range(nn-1):
  n = nn-i
  s = ss[i:]
  a = [0]*n
  a[0] = n
  i, j = 1, 0
  while i < n:
    while i+j < n and s[j] == s[i+j]:
      j += 1
    a[i] = j
    if j == 0:
      i += 1
      continue
    k = 1
    while i+k < n and k+a[k] < j:
      a[i+k] = a[k]
      k += 1
    i += k
    j -= k
  for p in range(1, n-1):
    a[p] = min([p, a[p]])
  sub = max(a[1:])
  if ans < sub:
    ans = sub
print(ans)