from string import ascii_lowercase



n = int(eval(input()))

s = eval(input())



ans = -1

for mid in range(1, n):

    # [0, mid), [mid, n)

    left = set(s[:mid])

    right = set(s[mid:])



    cnt = 0

    for c in ascii_lowercase:

        if c in left and c in right:

            cnt += 1

    ans = max(ans, cnt)

print(ans)

def main():

    N = int(eval(input()))

    s = eval(input())



    acc = []

    t = [0] * 26

    for c in s:

        i = ord(c) - ord('a')

        t[i] += 1

        acc.append(t.copy())



    ans = 0

    for i in range(N - 1):

        left = acc[i]

        right = [cn - ci for ci, cn in zip(acc[i], acc[N - 1])]

        cnt = 0

        for ci in range(26):

            if left[ci] and right[ci]:

                cnt += 1

            ans = max(ans, cnt)

    print(ans)





if __name__ == '__main__':

    main()

from string import ascii_lowercase

n = int(eval(input()))
s = eval(input())
ans = -1
for mid in range(1, n):
    # [0, mid), [mid, n)
    left = set(s[:mid])
    right = set(s[mid:])
    cnt = 0
    for c in ascii_lowercase:
        if c in left and c in right:
            cnt += 1
    ans = max(ans, cnt)
print(ans)

def main():
    N = int(eval(input()))
    s = eval(input())
    acc = []
    t = [0] * 26
    for c in s:
        i = ord(c) - ord("a")
        t[i] += 1
        acc.append(t.copy())
    ans = 0
    for i in range(N - 1):
        left = acc[i]
        right = [cn - ci for ci, cn in zip(acc[i], acc[N - 1])]
        cnt = 0
        for ci in range(26):
            if left[ci] and right[ci]:
                cnt += 1
            ans = max(ans, cnt)
    print(ans)


if __name__ == "__main__":
    main()

-from string import ascii_lowercase +def main(): +    N = int(eval(input())) +    s = eval(input()) +    acc = [] +    t = [0] * 26 +    for c in s: +        i = ord(c) - ord("a") +        t[i] += 1 +        acc.append(t.copy()) +    ans = 0 +    for i in range(N - 1): +        left = acc[i] +        right = [cn - ci for ci, cn in zip(acc[i], acc[N - 1])] +        cnt = 0 +        for ci in range(26): +            if left[ci] and right[ci]: +                cnt += 1 +            ans = max(ans, cnt) +    print(ans) -n = int(eval(input())) -s = eval(input()) -ans = -1 -for mid in range(1, n): -    # [0, mid), [mid, n) -    left = set(s[:mid]) -    right = set(s[mid:]) -    cnt = 0 -    for c in ascii_lowercase: -        if c in left and c in right: -            cnt += 1 -    ans = max(ans, cnt) -print(ans) + +if __name__ == "__main__": +    main()