N = int(input())
S = input()
from collections import deque

def f(m):
    se = set()
    q = deque()
    for i in range(0,N-m+1):
        h = hash(S[i:i+m])
        q.append(h)
        if h in se:
            return True
        if len(q) >= m:
            se.add(q.popleft())
    return False

l = 0
r = N//2+1
while (r-l)>1:
    mid = (r+l)//2
    if f(mid):
        l = mid
    else:
        r = mid
print(l) N = int(input()) N int(input()) int input() input S = input() S input() input from collections import deque def f(m):
    se = set()
    q = deque()
    for i in range(0,N-m+1):
        h = hash(S[i:i+m])
        q.append(h)
        if h in se:
            return True
        if len(q) >= m:
            se.add(q.popleft())
    return False f se = set() se set() set q = deque() q deque() deque for i in range(0,N-m+1):
        h = hash(S[i:i+m])
        q.append(h)
        if h in se:
            return True
        if len(q) >= m:
            se.add(q.popleft())
     i range(0,N-m+1) range 0 N-m+1 N-m N m 1 h = hash(S[i:i+m]) h hash(S[i:i+m]) hash S[i:i+m] S i:i+m i i+m i m q.append(h) q.append q append h if h in se:
            return True
         h in se h se return True True if len(q) >= m:
            se.add(q.popleft())
     len(q) >= m len(q) len q m se.add(q.popleft()) se.add se add q.popleft() q.popleft q popleft return False False m m l = 0 l 0 r = N//2+1 r N//2+1 N//2 N 2 1 while (r-l)>1:
    mid = (r+l)//2
    if f(mid):
        l = mid
    else:
        r = mid (r-l)>1 r-l r l 1 mid = (r+l)//2 mid (r+l)//2 r+l r l 2 if f(mid):
        l = mid
    else:
        r = mid f(mid) f mid l = mid l mid r = mid r mid print(l) print l r = mid mid r l = 0 0 l mid = (r+l)//2 (r+l)//2 mid r = N//2+1 N//2+1 r N = int(input()) int(input()) N def f(m):
    se = set()
    q = deque()
    for i in range(0,N-m+1):
        h = hash(S[i:i+m])
        q.append(h)
        if h in se:
            return True
        if len(q) >= m:
            se.add(q.popleft())
    return False def f(m):
    se = set()
    q = deque()
    for i in range(0,N-m+1):
        h = hash(S[i:i+m])
        q.append(h)
        if h in se:
            return True
        if len(q) >= m:
            se.add(q.popleft())
    return False f S = input() input() S l = mid mid l
N = int(input())
S = input()
from collections import deque

def f(m):
    se = set()
    q = deque()
    for i in range(0,N-m+1):
        h = hash(S[i:i+m])
        q.append(h)
        if h in se:
            return True
        if len(q) >= m:
            se.add(q.popleft())
    return False

l = 0
r = N//2+1
while (r-l)>1:
    mid = (r+l)//2
    if f(mid):
        l = mid
    else:
        r = mid
print(l)