import collections

n = int(input())

s = input()



def f(k, s):	

	if k == 0:

		return True

 	cc = collections.Counter()

	q = collections.deque()

	for j in range(k - 1, len(s)):

		q.append(s[j - k + 1:j+1])

		if len(q) == k + 1:

			u = q.popleft()

			cc[u] += 1

		if s[j- k+1:j+1] in cc:

			return True	

	return False

lo,hi = 0, n/2 + 1

while(lo < hi):

	med = (lo + hi + 1) / 2

	if f(med, s):

		lo = med

	else:

		hi = med - 1



print(lo)
import collections

n,s = int(input()), input()



def f(k, s):	

 	cc,q = collections.Counter(), collections.deque()

	for j in range(k - 1, len(s)):

		q.append(s[j - k + 1:j+1])

		if len(q) == k + 1: cc[q.popleft()] += 1

		if q[-1] in cc: return True	

	return False



lo,hi = 0, n/2

while(lo < hi):

	med = (lo + hi + 1) / 2

	if f(med, s):  lo = med

	else:hi = med - 1

print(lo)
import collections

n = int(input())
s = input()


def f(k, s):
    if k == 0:
        return True
    cc = collections.Counter()
    q = collections.deque()
    for j in range(k - 1, len(s)):
        q.append(s[j - k + 1 : j + 1])
        if len(q) == k + 1:
            u = q.popleft()
            cc[u] += 1
        if s[j - k + 1 : j + 1] in cc:
            return True
    return False


lo, hi = 0, n / 2 + 1
while lo < hi:
    med = (lo + hi + 1) / 2
    if f(med, s):
        lo = med
    else:
        hi = med - 1
print(lo)

import collections

n, s = int(input()), input()


def f(k, s):
    cc, q = collections.Counter(), collections.deque()
    for j in range(k - 1, len(s)):
        q.append(s[j - k + 1 : j + 1])
        if len(q) == k + 1:
            cc[q.popleft()] += 1
        if q[-1] in cc:
            return True
    return False


lo, hi = 0, n / 2
while lo < hi:
    med = (lo + hi + 1) / 2
    if f(med, s):
        lo = med
    else:
        hi = med - 1
print(lo)

-n = int(input()) -s = input() +n, s = int(input()), input() -    if k == 0: -        return True -    cc = collections.Counter() -    q = collections.deque() +    cc, q = collections.Counter(), collections.deque() -            u = q.popleft() -            cc[u] += 1 -        if s[j - k + 1 : j + 1] in cc: +            cc[q.popleft()] += 1 +        if q[-1] in cc: -lo, hi = 0, n / 2 + 1 +lo, hi = 0, n / 2