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

s = s[:n]
alph = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q', 'r','s','t']

alph_len = len(alph)
initial = [0 for i in range(alph_len)]
sums = []

initial[alph.index(s[0])] = 1
sums.append(initial)
for i in range(1, n):
    copy = sums[i-1].copy()
    copy[alph.index(s[i])] += 1
    sums.append(copy)

arr = []
arr.append([0, n-1])

res = []

def sim(i, j, s, sums):
    newsum = []
    for a in range(len(sums[j])):
        if i == 0:
            newsum.append(sums[j][a])
        else:
            newsum.append(sums[j][a] - sums[i][a])
    
    odds = 0
    for a in newsum:
        if a % 2 == 1:
            odds += 1
    
    return odds == 1 or odds == 0

while True:
    tmp = arr.pop()
    i = tmp[0]
    j = tmp[1]
    
    if sim(i, j, s, sums):
        res.append(j-i+1)

    if(i == j):
        break
    else:
        arr.append([i+1, j])
        arr.append([i, j-1])
    

print(max(res))

# print(l)
