n = int(eval(input()))

l = list(eval(input()))

ans = 0

for i in range(n):

  l1 = l[i+1:]

  

  count = set()

  for j in range(i+1):

    if l[j] in l1:

      count.add(l[j])

  ans = max(ans,len(count))

  

print(ans)

n = int(eval(input()))

l = list(eval(input()))

ans = 0

for i in range(n):

    count = len(set(l[:i])&set(l[i:]))

    ans = max(count,ans)

print(ans)
n = int(eval(input()))
l = list(eval(input()))
ans = 0
for i in range(n):
    l1 = l[i + 1 :]
    count = set()
    for j in range(i + 1):
        if l[j] in l1:
            count.add(l[j])
    ans = max(ans, len(count))
print(ans)

n = int(eval(input()))
l = list(eval(input()))
ans = 0
for i in range(n):
    count = len(set(l[:i]) & set(l[i:]))
    ans = max(count, ans)
print(ans)

-    l1 = l[i + 1 :] -    count = set() -    for j in range(i + 1): -        if l[j] in l1: -            count.add(l[j]) -    ans = max(ans, len(count)) +    count = len(set(l[:i]) & set(l[i:])) +    ans = max(count, ans)