days = int(input())
mugs = input()
length = len(mugs)

brands = {}

def is_valid():
    oddCount = 0
    for brand in brands.values():
        if brand % 2 != 0:
            oddCount += 1
        if oddCount > 1:
            return False
    return True

for mug in mugs:
    if mug not in brands:
        brands.update({mug: 1})
    else:
        brands.update({mug: brands[mug] + 1})

max = 0
if is_valid():
    print(length)
    quit()

for i in range(len(mugs) - 1, -1 , -1):
        brands.update({mugs[i]: brands[mugs[i]] - 1})
        length -= 1
        if is_valid():
            print(length)
            quit()
print(max)



