def rolling_hash(s):
    l = len(s)
    h = [0]*(l + 1)
    v = 0
    for i in range(l):
        h[i+1] = v = (v * base + ord(s[i])) % mod
    return h
def setup_pw(l):
    pw = [1]*(l + 1)
    v = 1
    for i in range(l):
        pw[i+1] = v = v * base % mod
    return pw
def get(h, b, l, r):
    return (h[r] - h[l] * b[r-l]) % mod

def check_bisect(l,h1,b1,h2,b2):
    for j in range(N-2*l+1):
        a1 = get(h1,b1,j,l+j)
        a2 = get(h2,b2,j,l+j)
        for k in range(N-2*l-j+1):
            if a1 == get(h1,b1,j+l+k,2*l+j+k) and a2 == get(h2,b2,j+l+k,2*l+j+k):
                return True
    return False

N = int(input())
S = input()
mod = 1000000007
base = 37
h1 = rolling_hash(S)
b1 = setup_pw(N)
base = 401
h2 = rolling_hash(S)
b2 = setup_pw(N)
left = 1
right = N // 2
finish = False
if N <= 26:
    s = set(list(S))
    if N <= 3:
        if len(s) < N:
            print('1')
        else:
            print('0')
        finish = True
    else:
        if len(s) == N:
            print('0')
            finish = True
while finish == False:
    if left == right:
        print(left)
        finish = True
    elif right - left == 1:
        if check_bisect(right,h1,b1,h2,b2):
            print(right)
        else:
            print(left)
        finish = True
    else:
        mid = (left+right) // 2
        if check_bisect(mid,h1,b1,h2,b2):
            left = mid
        else:
            right = mid - 1 def rolling_hash(s):
    l = len(s)
    h = [0]*(l + 1)
    v = 0
    for i in range(l):
        h[i+1] = v = (v * base + ord(s[i])) % mod
    return h rolling_hash l = len(s) l len(s) len s h = [0]*(l + 1) h [0]*(l + 1) [0] 0 l + 1 l 1 v = 0 v 0 for i in range(l):
        h[i+1] = v = (v * base + ord(s[i])) % mod
     i range(l) range l h[i+1] = v = (v * base + ord(s[i])) % mod h[i+1] h i+1 i 1 (v * base + ord(s[i])) % mod v * base + ord(s[i]) v * base v base ord(s[i]) ord s[i] s i mod = v = (v * base + ord(s[i])) % mod v (v * base + ord(s[i])) % mod return h h s s def setup_pw(l):
    pw = [1]*(l + 1)
    v = 1
    for i in range(l):
        pw[i+1] = v = v * base % mod
    return pw setup_pw pw = [1]*(l + 1) pw [1]*(l + 1) [1] 1 l + 1 l 1 v = 1 v 1 for i in range(l):
        pw[i+1] = v = v * base % mod
     i range(l) range l pw[i+1] = v = v * base % mod pw[i+1] pw i+1 i 1 v * base % mod v * base v base mod = v = v * base % mod v v * base % mod return pw pw l l def get(h, b, l, r):
    return (h[r] - h[l] * b[r-l]) % mod get return (h[r] - h[l] * b[r-l]) % mod (h[r] - h[l] * b[r-l]) % mod h[r] - h[l] * b[r-l] h[r] h r h[l] * b[r-l] h[l] h l b[r-l] b r-l r l mod h h b b l l r r def check_bisect(l,h1,b1,h2,b2):
    for j in range(N-2*l+1):
        a1 = get(h1,b1,j,l+j)
        a2 = get(h2,b2,j,l+j)
        for k in range(N-2*l-j+1):
            if a1 == get(h1,b1,j+l+k,2*l+j+k) and a2 == get(h2,b2,j+l+k,2*l+j+k):
                return True
    return False check_bisect for j in range(N-2*l+1):
        a1 = get(h1,b1,j,l+j)
        a2 = get(h2,b2,j,l+j)
        for k in range(N-2*l-j+1):
            if a1 == get(h1,b1,j+l+k,2*l+j+k) and a2 == get(h2,b2,j+l+k,2*l+j+k):
                return True
     j range(N-2*l+1) range N-2*l+1 N-2*l N 2*l 2 l 1 a1 = get(h1,b1,j,l+j) a1 get(h1,b1,j,l+j) get h1 b1 j l+j l j a2 = get(h2,b2,j,l+j) a2 get(h2,b2,j,l+j) get h2 b2 j l+j l j for k in range(N-2*l-j+1):
            if a1 == get(h1,b1,j+l+k,2*l+j+k) and a2 == get(h2,b2,j+l+k,2*l+j+k):
                return True
     k range(N-2*l-j+1) range N-2*l-j+1 N-2*l-j N-2*l N 2*l 2 l j 1 if a1 == get(h1,b1,j+l+k,2*l+j+k) and a2 == get(h2,b2,j+l+k,2*l+j+k):
                return True
     a1 == get(h1,b1,j+l+k,2*l+j+k) and a2 == get(h2,b2,j+l+k,2*l+j+k) a1 == get(h1,b1,j+l+k,2*l+j+k) a1 get(h1,b1,j+l+k,2*l+j+k) get h1 b1 j+l+k j+l j l k 2*l+j+k 2*l+j 2*l 2 l j k a2 == get(h2,b2,j+l+k,2*l+j+k) a2 get(h2,b2,j+l+k,2*l+j+k) get h2 b2 j+l+k j+l j l k 2*l+j+k 2*l+j 2*l 2 l j k return True True return False False l l h1 h1 b1 b1 h2 h2 b2 b2 N = int(input()) N int(input()) int input() input S = input() S input() input mod = 1000000007 mod 1000000007 base = 37 base 37 h1 = rolling_hash(S) h1 rolling_hash(S) rolling_hash S b1 = setup_pw(N) b1 setup_pw(N) setup_pw N base = 401 base 401 h2 = rolling_hash(S) h2 rolling_hash(S) rolling_hash S b2 = setup_pw(N) b2 setup_pw(N) setup_pw N left = 1 left 1 right = N // 2 right N // 2 N 2 finish = False finish False if N <= 26:
    s = set(list(S))
    if N <= 3:
        if len(s) < N:
            print('1')
        else:
            print('0')
        finish = True
    else:
        if len(s) == N:
            print('0')
            finish = True N <= 26 N 26 s = set(list(S)) s set(list(S)) set list(S) list S if N <= 3:
        if len(s) < N:
            print('1')
        else:
            print('0')
        finish = True
    else:
        if len(s) == N:
            print('0')
            finish = True N <= 3 N 3 if len(s) < N:
            print('1')
        else:
            print('0')
         len(s) < N len(s) len s N print('1') print '1' print('0') print '0' finish = True finish True if len(s) == N:
            print('0')
            finish = True len(s) == N len(s) len s N print('0') print '0' finish = True finish True while finish == False:
    if left == right:
        print(left)
        finish = True
    elif right - left == 1:
        if check_bisect(right,h1,b1,h2,b2):
            print(right)
        else:
            print(left)
        finish = True
    else:
        mid = (left+right) // 2
        if check_bisect(mid,h1,b1,h2,b2):
            left = mid
        else:
            right = mid - 1 finish == False finish False if left == right:
        print(left)
        finish = True
    elif right - left == 1:
        if check_bisect(right,h1,b1,h2,b2):
            print(right)
        else:
            print(left)
        finish = True
    else:
        mid = (left+right) // 2
        if check_bisect(mid,h1,b1,h2,b2):
            left = mid
        else:
            right = mid - 1 left == right left right print(left) print left finish = True finish True elif right - left == 1:
        if check_bisect(right,h1,b1,h2,b2):
            print(right)
        else:
            print(left)
        finish = True
     right - left == 1 right - left right left 1 if check_bisect(right,h1,b1,h2,b2):
            print(right)
        else:
            print(left)
         check_bisect(right,h1,b1,h2,b2) check_bisect right h1 b1 h2 b2 print(right) print right print(left) print left finish = True finish True mid = (left+right) // 2 mid (left+right) // 2 left+right left right 2 if check_bisect(mid,h1,b1,h2,b2):
            left = mid
        else:
            right = mid - 1 check_bisect(mid,h1,b1,h2,b2) check_bisect mid h1 b1 h2 b2 left = mid left mid right = mid - 1 right mid - 1 mid 1 right = mid - 1 mid - 1 right S = input() input() S b1 = setup_pw(N) setup_pw(N) b1 base = 37 37 base s = set(list(S)) set(list(S)) s N = int(input()) int(input()) N h1 = rolling_hash(S) rolling_hash(S) h1 finish = True True finish def get(h, b, l, r):
    return (h[r] - h[l] * b[r-l]) % mod def get(h, b, l, r):
    return (h[r] - h[l] * b[r-l]) % mod get mid = (left+right) // 2 (left+right) // 2 mid mod = 1000000007 1000000007 mod finish = True True finish base = 401 401 base left = 1 1 left finish = False False finish left = mid mid left finish = True True finish def rolling_hash(s):
    l = len(s)
    h = [0]*(l + 1)
    v = 0
    for i in range(l):
        h[i+1] = v = (v * base + ord(s[i])) % mod
    return h def rolling_hash(s):
    l = len(s)
    h = [0]*(l + 1)
    v = 0
    for i in range(l):
        h[i+1] = v = (v * base + ord(s[i])) % mod
    return h rolling_hash def setup_pw(l):
    pw = [1]*(l + 1)
    v = 1
    for i in range(l):
        pw[i+1] = v = v * base % mod
    return pw def setup_pw(l):
    pw = [1]*(l + 1)
    v = 1
    for i in range(l):
        pw[i+1] = v = v * base % mod
    return pw setup_pw right = N // 2 N // 2 right def check_bisect(l,h1,b1,h2,b2):
    for j in range(N-2*l+1):
        a1 = get(h1,b1,j,l+j)
        a2 = get(h2,b2,j,l+j)
        for k in range(N-2*l-j+1):
            if a1 == get(h1,b1,j+l+k,2*l+j+k) and a2 == get(h2,b2,j+l+k,2*l+j+k):
                return True
    return False def check_bisect(l,h1,b1,h2,b2):
    for j in range(N-2*l+1):
        a1 = get(h1,b1,j,l+j)
        a2 = get(h2,b2,j,l+j)
        for k in range(N-2*l-j+1):
            if a1 == get(h1,b1,j+l+k,2*l+j+k) and a2 == get(h2,b2,j+l+k,2*l+j+k):
                return True
    return False check_bisect b2 = setup_pw(N) setup_pw(N) b2 h2 = rolling_hash(S) rolling_hash(S) h2 finish = True True finish
def rolling_hash(s):
    l = len(s)
    h = [0]*(l + 1)
    v = 0
    for i in range(l):
        h[i+1] = v = (v * base + ord(s[i])) % mod
    return h
def setup_pw(l):
    pw = [1]*(l + 1)
    v = 1
    for i in range(l):
        pw[i+1] = v = v * base % mod
    return pw
def get(h, b, l, r):
    return (h[r] - h[l] * b[r-l]) % mod

def check_bisect(l,h1,b1,h2,b2):
    for j in range(N-2*l+1):
        a1 = get(h1,b1,j,l+j)
        a2 = get(h2,b2,j,l+j)
        for k in range(N-2*l-j+1):
            if a1 == get(h1,b1,j+l+k,2*l+j+k) and a2 == get(h2,b2,j+l+k,2*l+j+k):
                return True
    return False

N = int(input())
S = input()
mod = 1000000007
base = 37
h1 = rolling_hash(S)
b1 = setup_pw(N)
base = 401
h2 = rolling_hash(S)
b2 = setup_pw(N)
left = 1
right = N // 2
finish = False
if N <= 26:
    s = set(list(S))
    if N <= 3:
        if len(s) < N:
            print('1')
        else:
            print('0')
        finish = True
    else:
        if len(s) == N:
            print('0')
            finish = True
while finish == False:
    if left == right:
        print(left)
        finish = True
    elif right - left == 1:
        if check_bisect(right,h1,b1,h2,b2):
            print(right)
        else:
            print(left)
        finish = True
    else:
        mid = (left+right) // 2
        if check_bisect(mid,h1,b1,h2,b2):
            left = mid
        else:
            right = mid - 1