N = int(input())
S = input()

def kAlgo(S, N):
    szS = N
    Z = [0]*szS
    Z[0] = szS
    i = 1 #current pos
    j = 0 #伸ばす幅
    while i < szS:
        while (i + j < szS) and (S[j] == S[i+j]): j += 1
        #set Z[i]
        Z[i] = j

        if j == 0:
            i += 1
            continue

        #optimize
        k = 1
        while (k < j) and (k + Z[k] < j):
            Z[i+k] = Z[k]
            k += 1

        i += k
        j -= k

    ans = 0
    for i in range(N):
        if Z[i] > i: Z[i] = i
    return max(Z[1:])

ans = 0
for i in range(N-1):
    lenz = kAlgo(S[i:], N-i)
    if ans < lenz:
        ans = lenz

print(ans) N = int(input()) N int(input()) int input() input S = input() S input() input def kAlgo(S, N):
    szS = N
    Z = [0]*szS
    Z[0] = szS
    i = 1 #current pos
    j = 0 #伸ばす幅
    while i < szS:
        while (i + j < szS) and (S[j] == S[i+j]): j += 1
        #set Z[i]
        Z[i] = j

        if j == 0:
            i += 1
            continue

        #optimize
        k = 1
        while (k < j) and (k + Z[k] < j):
            Z[i+k] = Z[k]
            k += 1

        i += k
        j -= k

    ans = 0
    for i in range(N):
        if Z[i] > i: Z[i] = i
    return max(Z[1:]) kAlgo szS = N szS N Z = [0]*szS Z [0]*szS [0] 0 szS Z[0] = szS Z[0] Z 0 szS i = 1 i 1 j = 0 j 0 while i < szS:
        while (i + j < szS) and (S[j] == S[i+j]): j += 1
        #set Z[i]
        Z[i] = j

        if j == 0:
            i += 1
            continue

        #optimize
        k = 1
        while (k < j) and (k + Z[k] < j):
            Z[i+k] = Z[k]
            k += 1

        i += k
        j -= k

     i < szS i szS while (i + j < szS) and (S[j] == S[i+j]): j += 1
        #set Z[i]
         (i + j < szS) and (S[j] == S[i+j]) i + j < szS i + j i j szS S[j] == S[i+j] S[j] S j S[i+j] S i+j i j Z[i] = j Z[i] Z i j if j == 0:
            i += 1
            continue

        #optimize
         j == 0 j 0 i += 1 i 1 continue k = 1 k 1 while (k < j) and (k + Z[k] < j):
            Z[i+k] = Z[k]
            k += 1

         (k < j) and (k + Z[k] < j) k < j k j k + Z[k] < j k + Z[k] k Z[k] Z k j Z[i+k] = Z[k] Z[i+k] Z i+k i k Z[k] Z k k += 1 k 1 i += k i k j -= k j k ans = 0 ans 0 for i in range(N):
        if Z[i] > i: Z[i] = i
     i range(N) range N if Z[i] > i: Z[i] = i
     Z[i] > i Z[i] Z i i return max(Z[1:]) max(Z[1:]) max Z[1:] Z 1: 1 S S N N ans = 0 ans 0 for i in range(N-1):
    lenz = kAlgo(S[i:], N-i)
    if ans < lenz:
        ans = lenz i range(N-1) range N-1 N 1 lenz = kAlgo(S[i:], N-i) lenz kAlgo(S[i:], N-i) kAlgo S[i:] S i: i N-i N i if ans < lenz:
        ans = lenz ans < lenz ans lenz ans = lenz ans lenz print(ans) print ans lenz = kAlgo(S[i:], N-i) kAlgo(S[i:], N-i) lenz def kAlgo(S, N):
    szS = N
    Z = [0]*szS
    Z[0] = szS
    i = 1 #current pos
    j = 0 #伸ばす幅
    while i < szS:
        while (i + j < szS) and (S[j] == S[i+j]): j += 1
        #set Z[i]
        Z[i] = j

        if j == 0:
            i += 1
            continue

        #optimize
        k = 1
        while (k < j) and (k + Z[k] < j):
            Z[i+k] = Z[k]
            k += 1

        i += k
        j -= k

    ans = 0
    for i in range(N):
        if Z[i] > i: Z[i] = i
    return max(Z[1:]) def kAlgo(S, N):
    szS = N
    Z = [0]*szS
    Z[0] = szS
    i = 1 #current pos
    j = 0 #伸ばす幅
    while i < szS:
        while (i + j < szS) and (S[j] == S[i+j]): j += 1
        #set Z[i]
        Z[i] = j

        if j == 0:
            i += 1
            continue

        #optimize
        k = 1
        while (k < j) and (k + Z[k] < j):
            Z[i+k] = Z[k]
            k += 1

        i += k
        j -= k

    ans = 0
    for i in range(N):
        if Z[i] > i: Z[i] = i
    return max(Z[1:]) kAlgo ans = lenz lenz ans ans = 0 0 ans N = int(input()) int(input()) N S = input() input() S
N = int(input())
S = input()

def kAlgo(S, N):
    szS = N
    Z = [0]*szS
    Z[0] = szS
    i = 1 #current pos
    j = 0 #伸ばす幅
    while i < szS:
        while (i + j < szS) and (S[j] == S[i+j]): j += 1
        #set Z[i]
        Z[i] = j

        if j == 0:
            i += 1
            continue

        #optimize
        k = 1
        while (k < j) and (k + Z[k] < j):
            Z[i+k] = Z[k]
            k += 1

        i += k
        j -= k

    ans = 0
    for i in range(N):
        if Z[i] > i: Z[i] = i
    return max(Z[1:])

ans = 0
for i in range(N-1):
    lenz = kAlgo(S[i:], N-i)
    if ans < lenz:
        ans = lenz

print(ans)
