You are given a string S of length N consisting of lowercase English letters.
We will cut this string at one position into two strings X and Y.
Here, we would like to maximize the number of different letters contained in both X and Y.
Find the largest possible number of different letters contained in both X and Y when we cut the string at the optimal position.

-----Constraints-----
 - 2 \leq N \leq 100
 - |S| = N
 - S consists of lowercase English letters.

-----Input-----
Input is given from Standard Input in the following format:
N
S

-----Output-----
Print the largest possible number of different letters contained in both X and Y.

-----Sample Input-----
6
aabbca

-----Sample Output-----
2

If we cut the string between the third and fourth letters into X = aab and Y = bca, the letters contained in both X and Y are a and b.
There will never be three or more different letters contained in both X and Y, so the answer is 2.

Difficulty: introductory

Starter code:

Solutions:
#
# abc096 b
#
import sys
from io import StringIO
import unittest
from collections import Counter


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """6
aabbca"""
        output = """2"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """10
aaaaaaaaaa"""
        output = """1"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """45
tgxgdqkyjzhyputjjtllptdfxocrylqfqjynmfbfucbir"""
        output = """9"""
        self.assertIO(input, output)


def resolve():
    N = int(input())
    S = input()

    ans = 0
    for i in range(1, N-1):
        x = Counter(S[0:i])
        y = S[i:]
        tmp = 0
        for j in list(x.keys()):
            if j in y:
                tmp += 1
        ans = max(ans, tmp)

    print(ans)


def __starting_point():
    # unittest.main()
    resolve()

__starting_point()

N = int(input())
S = input()

ans = 0
for i in range(1,N-1):
  set1 = set(S[:i])
  set2 = set(S[i:])
  z = set1.intersection(set2)
  ans = max(ans,len(z))

print(ans)


N = int(input())
S = input()
ans = 0
for i in range(1, N):
    L = set(S[:i])
    R = set(S[i:])
    ans = max(ans, len(L & R))

print(ans)

n = int(input())
s = list(input())
ans = 0
for i in range(1, n):
    count = 0
    x = sorted(set(s[:i]))
    y = sorted(set(s[i:]))
    for j in x:
        if j in y:
            count += 1
    ans = max(ans, count)
print(ans)

n = int(input())
s = input()
ans = 0
for i in range(n-1):
    front = set(s[:i+1])
    back = set(s[i+1:])
    ans = max(ans, len(front&back))
print(ans)

N = int(input())
S = input()

cnt = 0
for i in range(N):
    s1 = set(S[:i])
    s2 = set(S[i:])
    l: int = len(s1 & s2)
    if l > cnt:
        cnt = l

print(cnt)


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

def check(a,b):
  c = [0] * 26
  d = [0] * 26
  for i in range(len(a)):
    c[ord(a[i])-97] = 1
  for i in range(len(b)):
    d[ord(b[i])-97] = 1
  ans = 0
  for i in range(26):
    if c[i] == 1 and d[i] == 1:
      ans += 1
  return ans

res = 0
for i in range(n):
  res = max(res,check(s[:i],s[i:]))
print(res)


_ = input()
S = input()

print(max([len(set(S[:i]) & set(S[i:])) for i in range(len(S))]))

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

x=[]

for i in range(n):
    a=s[:i]
    b=s[i:]
    cnt=0
    c=set(a)
    d=set(b)
    c=list(c)
    d=list(d)
    for j in range(len(c)):
        for k in range(len(d)):
            if c[j]==d[k]:
                cnt+=1
                break
    x.append(cnt)

print(max(x))

n=int(input())
s=input()
print(max(len(set(s[:i])&set(s[i:])) for i in range(n)))

N = int(input())
S = input()

list1 =  []
for i in range(N):
  x = set()
  
  for s in S[:i+1]:
    if s in S[i+1:]:
      x.add(s)
  list1.append(len(x))
print(max(list1))

n=int(input())
S=input()
ans=0
for i in range(1,len(S)):
  S1=S[:i]
  S2=S[i:]
  cnt = set()
  for s1 in S1:
    if s1 in S2:
      cnt.add(s1)
  ans = max(ans,len(cnt))
print(ans)

n=int(input())
s=input()
ans=0
for i in range(1,n):
  cnt=0
  l=set (s[:i])
  r=set (s[i:])
  for v in l:
    if v in r:
      cnt+=1
  ans=max(ans,cnt)
print(ans)

N = int(input())
S = input()

max_cnt = 0
for i in range(1, N):
    x = set(S[0:i])
    y = set(S[i:N])
    x_y = len(x & y)
    
    if x_y > max_cnt:
        max_cnt = x_y
        
print(max_cnt)

n = int(input())
s = list(input())
ans = 0
c = 0
fh = []
lh = s
for i in range(n):
  tmp = lh.pop(0)
  if tmp not in fh:
    if tmp in lh:
      c += 1
  elif tmp not in lh:
    c -= 1
  fh.append(tmp)
  ans = max(ans, c)
print(ans)

n=int(input())
s=input()
ans=0
for i in range(n-1):
    a=set()
    b=set()
    for j in range(i):
        a.add(s[j])
    for j in range(i,n):
        b.add(s[j])
    ans=max(ans,len(a&b))
print(ans)

N = int(input())
S = input()

max_counter = 0
for i in range(1, N-1):
    x = set(S[0:i])
    y = set(S[i:N])
    if len(x & y) > max_counter:
        max_counter = len(x & y)

print(max_counter)

N = int(input())
S = input()
list = [0]*N
for i in range(N):
    A = S[:i]
    B = S[i:]
    A = set(A)
    B = set(B)
    for j in A:
      if j in B:
        list[i] += 1
list = sorted(list)
print(list[-1])

n = int(input())
s = input()
c = 0
for i in range(1,n-1):
  x = set(s[:i])
  y = set(s[i:])
  cap = x&y
  c = max(c,len(cap))
print(c)

n = int(input())
s = input()
a = []
for i in range(1, len(s)):
    s1 = list(s[:i])
    s2 = list(s[i:])
    b = []
    for j in s1:
        if j in s2 and j not in b:
            b.append(j)
    a.append(len(b))
print(max(a))

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

ans=0
for i in range(1,n):
  be_s=set(s[:i])
  af_s=set(s[i:])
  num=len(be_s & af_s)
  ans=max(ans,num)
  
print(ans)

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

count = []
for i in range(1,n):
    first = s[:i]
    second= s[i:]
    # print(first,second)
    count.append(len(set(first)&set(second)))

# print(count)
print((max(count)))


n = int(input())
s = input()
L = ""
R = ""
C = ""
tmp = 0
ans = []
for i in range(1, len(s)):
    L = s[:i]
    R = s[i:]
    C = len(set(L) & set(R))
    ans.append(C)
    L = ""
    R = ""
print(max(ans))

import sys
lines = [s.rstrip("\n") for s in sys.stdin.readlines()]
n, = [int(num) for num in lines.pop(0).split(" ")]
s = lines.pop(0)

ans = 0
for i in range(n):
    intersection = set(s[:i]) & set(s[i:])
    num = len(intersection)
    if num > ans:
        ans = num
print(ans)


N = int(input())
S = [i for i in input()]
ANS = []

for i in range(1, N+1):
    ans = 0
    A = []
    B = []
    A = list(set(S[:i]))
    B = list(set(S[i:]))
    for a in A:
        for b in B:
            if a == b:
                ans += 1
    ANS.append(ans)
print(max(ANS))

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

ans = 0

for i in range(n):
    #複数のリストから共通する要素を抽出
    ans = max(ans, len(set(list(s[:i])) & set(list(s[i:]))))

print(ans)

n = int(input())
s = input()
ans = 0
for i in range(1, n+1):
    cnt = 0
    x = s[0:i]
    y = s[i:n+1]
    for j in range(97, 123):
        if chr(j) in x and chr(j) in y:
            cnt += 1
    ans = max(cnt, ans)
print(ans)

n = int(input())
s = input()
c = 0
for i in range(n-1):
    xy=set(s[i+1:])&set(s[:i+1])
    c = max(c,len(xy))
print(c)

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

alphabets = [chr(i + 97) for i in range(26)]

# forward
l1 = [0] * (n-1)
now = [False] * 26
for i in range(n-1):
    now[ord(s[i]) - 97] = True
    l1[i] = now.copy()

# backward
l2 = [0] * (n-1)
now = [False] * 26
for i in range(n-1, 0, -1):
    now[ord(s[i]) - 97] = True
    l2[i-1] = now.copy()

ans = 0
for i in range(n-1):
    cnt = 0
    for j in range(26):
        if l1[i][j] and l2[i][j]:
            cnt += 1

    if ans < cnt:
        ans = cnt

print(ans)

N = int(input())
S = input()

cnt = []
for n in range(1, N):
    x = sorted(S[:n])
    y = sorted(S[n:])
    cnt.append(len(set(x)&set(y)))
        
print(max(cnt))

n = int(input())
s = input()
count = 0
ans = 0
for i in range(0, n - 1):
    x = list(s[:i + 1])
    y = list(s[i + 1:])
    for c in range(ord('a'), ord('z') + 1):
        if chr(c) in x and chr(c) in y:
            count += 1
    if ans < count:
        ans = count
    count = 0
print(ans)

import collections
n = int(input())
s = input()
ans = 0
for l in range(1,n):
  s1 = s[:l]
  s2 = s[l:]
  s1 = collections.Counter(s1)
  s2 = collections.Counter(s2)
  num = 0
  for i in s1:
    if i in s2:
      num += 1
      ans = max(ans,num)
print(ans)

N = int(input())
S = input()

print(max([len(set(list(S[:i])) & set(list(S[i:]))) for i in range(N)]))

n = int(input())
s = input()
ans = []
for i in range(1,n):
    cnt = 0
    A = set(s[:i])
    B = set(s[i:])
    for j in A:
        if j in B:
            cnt += 1
    ans.append(cnt)
print(max(ans))

n = int(input())
s = input()
mx = -1
for i in range(1,n):
    x = set(s[0:i])
    y = set(s[i:])
    mx = max(mx,len(x&y))
print(mx)
    


n = int(input())
s = input()
ans = 0

for i in range(1,len(s)):
  s1 = s[:i]
  s2 = s[i:]
  cnt = set()
  for j in s1:
    if j in s2:
      cnt.add(j)
  ans = max(ans,len(cnt))
print(ans)


N = int(input())
S = input()

ans = 0
for i in range(N):
    l = S[:i]
    r = S[i:]
    now = len(set(l) & set(r))
    ans = max(ans, now)
print(ans)

N = int(input())
S = list(input())
res = []

for i in range(1, N):
  res.append(len(set(S[:i]) & set(S[i:])))

print(max(res))

N = int(input())
S = input()

res = 0
for i in range(1,N):
    com = set(S[:i]) & set(S[i:])
    if res<len(com):
        res=len(com)
print(res)

N = int(input())
S = input()

def f(s, t):
  set_s = set()
  set_t = set()
  for i in s:
    set_s.add(i)
  for i in t:
    set_t.add(i)
  return len( set_s & set_t )

ans = 0
for i in range(1,N):
  s = S[i:]
  t = S[:i]
  ans = max(ans, f(s ,t))
print(ans)


N = int(input())
S = input()

ans = 0
for i in range(1,N):
    common = set(S[i:]) & set(S[:i])
    ans = max(ans,len(common))

print(ans)

#!/usr/local/bin/python3
# https://atcoder.jp/contests/abc098/tasks/abc098_b

N = int(input())
S = input()


def check(i):
    return len(set(S[:i]) & set(S[i:]))


ans = [0] * N
for i in range(N):
    ans[i] = check(i)

print((max(ans)))


import sys

input = sys.stdin.readline
N = int(input())
S = list(input().strip())

ans = 0
for i in range(N):
    ans = max(ans, len(set(S[:i]) & set(S[i:])))
print(ans)

n = int(input())
s = input()
alphabets = 'abcdefghijklmnopqrstuvwxyz'
max_chr = 0

for i in range(len(s)-1):
    cnt = 0
    for letter in alphabets:
        if (letter in s[:i+1]) and (letter in s[i+1:]):
            cnt += 1
    max_chr = max(max_chr, cnt)
print(max_chr)

n = int(input())
s = input()
ans = 0
for i in range(1,n):
    x,y = set(s[:i]),set(s[i:])
    ans = max(ans,len(x&y))
print(ans)

import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return list(map(int, input().split()))
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]

def main():
    n = i_input()
    s = s_input()
    ans = 0
    for i in range(n):
        l = set(s[:i])
        r = set(s[i:])
        trial = 0
        for k in l:
            if k in r:
                trial += 1
        ans = max(ans,trial)
    print(ans)



def __starting_point():
    main()

__starting_point()

N=int(input())
S=input()
ans=0
s="abcdefghijklmnopqrstuvwxyz"
for i in range(1,N):
    T1=S[0:i]
    T2=S[i:N]
    count=0
    for c in s:
        if c in T1 and c in T2:
            count+=1
    ans=max(ans,count)
print(ans)


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

cnt = 0
for i in range(1, n-1):
    tmp = 0
    r, l = s[:i], s[i:]
    rs = list(set(r))
    for ri in rs:
        if l.count(ri) > 0:
            tmp += 1
    cnt = max(cnt, tmp)

print(cnt)

N = int(input())
S = input()
ans = 0
for i in range(1, N - 1):
    ans = max(ans, len(set(S[:i]) & set(S[i:])))
print(ans)

N = int(input())
S = list(input())
dic = {}

for i in range(N):
  if S[i] not in dic.keys():
    dic[S[i]] = [i]
  else:
    dic[S[i]].append(i)
    
ans = 0
for j in range(1,N):
  cnt = 0
  for k in dic.values():
    check1 = False
    check2 = False
    for l in k:
      if l < j:
        check1 = True
      if j <= l:
        check2 = True
    if check1 and check2:
      cnt += 1
  ans = max(ans, cnt)
  
print(ans)

N=int(input())
S=input()
alf="abcdefghijklmnopqrstuvwxyz"
ans=0

for i in range(N-1):
    S1=list(S[0:i+1])
    S2=list(S[i+1:N])

    temp=0
    li1=[0]*26
    li2=[0]*26

    for j in range(len(S1)):
        li1[alf.find(S1[j])]+=1
    for k in range(len(S2)):
        li2[alf.find(S2[k])]+=1
    
    for l in range(26):
        if min(li1[l],li2[l])!=0:
            temp+=1
    if temp>ans:
        ans=temp
print(ans)


n = int(input())
s = input()
cnt = 0
for i in range(1,n):
    l = []
    for j in s[:i]:
        if j in s[i:]:
            l.append(j)
    l = set(l)
    cnt = max(cnt,len(l))

print(cnt)

N = int(input())
S = input()
ans = 0
for i in range(N):
    s1 = set(S[:i])
    s2 = set(S[i:])
    ans = max(len(s1 & s2), ans)
print(ans)

n=int(input())
s=input()
count = 0
for i in range(n-1):
  a=s[:i + 1]
  b=s[i+1:]
  temp = 0
  for j in range(27):
    if chr(96+j) in a and chr(96+j) in b:
      temp += 1
  count = max(temp, count)
print(count)

def main():
    n = int(input())
    s = input()
    ans = 0

    for i in range(1, n):
        cnt = 0
        x, y = set(s[:i]), set(s[i:])
        for j in x:
            if j in y:
                cnt += 1
        ans = max(ans, cnt)

    print(ans)


main()

n = int(input())
s = input()
ans = 0
for i in range(1,n):
  cnt = 0
  l = set(s[:i])
  r = set(s[i:])
  for v in l:
    if v in r:
      cnt += 1
  ans = max(ans,cnt)
print(ans)

#
# abc096 b
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """6
aabbca"""
        output = """2"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """10
aaaaaaaaaa"""
        output = """1"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """45
tgxgdqkyjzhyputjjtllptdfxocrylqfqjynmfbfucbir"""
        output = """9"""
        self.assertIO(input, output)


def resolve():
    N = int(input())
    S = input()

    ans = 0
    for i in range(1, N-1):
        x = set(S[0:i])
        y = set(S[i:])
        ans = max(ans, len(x & y))

    print(ans)


def __starting_point():
    # unittest.main()
    resolve()

__starting_point()

def al_cnt(k,s):
    count = 0
    if 'a' in s[:k] and 'a' in s[k:]:
        count += 1
    if 'b' in s[:k] and 'b' in s[k:]:
        count += 1
    if 'c' in s[:k] and 'c' in s[k:]:
        count += 1
    if 'd' in s[:k] and 'd' in s[k:]:
        count += 1
    if 'e' in s[:k] and 'e' in s[k:]:
        count += 1
    if 'f' in s[:k] and'f' in s[k:]:
        count += 1
    if 'g' in s[:k] and 'g' in s[k:]:
        count += 1
    if 'h' in s[:k] and 'h' in s[k:]:
        count += 1
    if 'i' in s[:k] and 'i' in s[k:]:
        count += 1
    if 'j' in s[:k] and 'j' in s[k:]:
        count += 1
    if 'k' in s[:k] and 'k' in s[k:]:
        count += 1
    if 'l' in s[:k] and 'l' in s[k:]:
        count += 1
    if 'm' in s[:k] and 'm' in s[k:]:
        count += 1
    if 'n' in s[:k] and 'n' in s[k:]:
        count += 1
    if 'o' in s[:k] and 'o' in s[k:]:
        count += 1
    if 'p' in s[:k] and 'p' in s[k:]:
        count += 1
    if 'q' in s[:k] and 'q' in s[k:]:
        count += 1
    if 'r' in s[:k] and 'r' in s[k:]:
        count += 1
    if 's' in s[:k] and 's' in s[k:]:
        count += 1
    if 't' in s[:k] and 't' in s[k:]:
        count += 1
    if 'u' in s[:k] and 'u' in s[k:]:
        count += 1
    if 'v' in s[:k] and 'v' in s[k:]:
        count += 1
    if 'w' in s[:k] and 'w' in s[k:]:
        count += 1
    if 'x' in s[:k] and 'x' in s[k:]:
        count += 1
    if 'y' in s[:k] and 'y' in s[k:]:
        count += 1
    if 'z' in s[:k] and 'z' in s[k:]:
        count += 1
    return count
n = int(input())
s = input()
ans = 0
for i in range(1,n-1):
    temp = al_cnt(i,s)
    ans = max(ans,temp)
print(ans)

N = int(input())
S = str(input())
_sum = 0
visited = set()
_sum_visited = set()
max_size = len(set(S))


for n in range(N-1):
  if S[n] in S[n+1:] and (S[n] not in visited):
    _sum += 1
  
  elif S[n] in visited and (S[n] not in S[n+1:]):
    _sum -= 1
  
  visited.add(S[n])
  _sum_visited.add(_sum)
  last_size = len(set(S[n+1]))
  ans = max(_sum_visited)
  if ans == max_size:
    break
    
print(max(_sum_visited))

N=int(input())
S=input()

ans = 0
for i in range(N):
	s1,s2=set(S[:i]),set(S[i:])
	tmp = len(s1.intersection(s2))
	if tmp > ans:ans=tmp


print(ans)

n = int(input())
S = input()

ans = 0
for i in range(1, n):
    X, Y = S[:i], S[i:]
    cnt = 0
    for x in set(X):
        if x in Y:
            cnt += 1
    ans = max(cnt, ans)
print(ans)

N = int(input())
S = input()

max_count = 0
for i in range(0, N-1):
  X = S[0:i+1]
  Y = S[i+1:]

  X_set = set(X)
  Y_set = set(Y)

  count = len(X_set & Y_set)
  if max_count < count:
    max_count = count

print(max_count)


N = int(input())
S = input()

print(max(len((set(S[:i]) & set(S[i:]))) for i in range(1, N)))

N = int(input())
S = list(input())

res = 0

for i in range(1, N):
    cnt = set(S[0:i]) & set(S[i:N])
    if res < len(cnt):
        res = len(cnt)

print(res)

n=int(input())
s=input()
count_list=[]

for i in range(1,n):
    x=s[:i]
    y=s[i:]
    xset=set(x)
    xlist=list(xset)
    count=0
    for j in xlist:
        if j in y:
            count+=1
    count_list.append(count)


print((max(count_list)))            


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

max_count = 0

for i in range(1, n):
    s1 = ''.join(set(s[:i]))
    s2 = ''.join(set(s[i:]))
    count = 0
    for j in range(len(s1)):
        if s1[j] in s2:
            count += 1
    if count > max_count:
        max_count = count
print(max_count)

from collections import Counter
N = int(input())
S = input()
ans = 0
for i in range(N):
    d1 = Counter(S[:i])
    d2 = Counter(S[i:])
    tmp = 0
    for alphabet in 'abcdefghijklmnopqrstuvwxyz':
        tmp += min(d1[alphabet], d2[alphabet], 1)
    print
    ans = max(ans, tmp)
print(ans)

N=int(input())
S=input()
tmp=0
ans=0
for i in range(N):
    A=set(S[:i])
    B=set(S[i:N])
    AB=A & B
    tmp=len(AB)
    if tmp > ans:
        ans=tmp
print(ans)
            


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

result = 0
for i in range(1,n):
  x = s[:i]
  y = s[i:]
  x_set = set(x)
  y_set = set(y)
  num = x_set & y_set
  result = max(result, len(num))
print(result)


n=int(input())
s=input()
tmp,ans=0,0
for i in range(n+1):
    s0=[]
    for j in range(n):
        if j<i:
            t=True
            for x in s0:
                if x==s[j]:t=False
            if t:s0.append(s[j])
        else:
            for k in range(len(s0)):
                if s0[k]==s[j]:
                    tmp+=1
                    s0[k]=-1
    #print(i,tmp)
    tmp,ans=0,max(ans,tmp)
print(ans)

input()
S = input()

print(max(len(set(S[:i]) & set(S[i:])) for i in range(len(S))))

n=int(input())
s=input()
data=[]
ans=0
for i in range(n-1):
  if s[i] not in data:
    data.append(s[i])
  res=0
  for j in data:
    if j in s[i+1:n]:
      res+=1
  ans=max(ans,res)
print(ans)

N = int(input())
N_List = list(map(str,input().strip()))
ans = 0
for i in range(1,N):
    c_ans = len(set(N_List[:i]) & set(N_List[i:]))
    if c_ans > ans:
        ans = c_ans
print(ans)

n = int(input())
s = input()
list_intersection = []

for i in range(1, n + 1):
    a = set(s[:i])
    b = set(s[i:])
    intersection_a_b = a.intersection(b)
    list_intersection.append(len(intersection_a_b))

print(max(list_intersection))

# len(set) 愚直
n = int(input())
s = list(input())
ans = 0
for i in range(1, n):
    x, y = set(s[:i]), set(s[i:])
    ans = max(ans, len(x & y))
print(ans)


N = int(input())
s = input()

result = 0
for i in range(N - 1):
  a = set(s[:i])
  b = set(s[i:])
  result = max(result, len(a & b))
  
print(result)

n = int(input())
s = input()
ans = 0
for i in range(1,n-1):
  a = set(s[:i])
  b = set(s[i:])
  q = max(len(a),len(b))
  t = 0
  if ans >= q:
      continue
  if len(a) >= len(b):
    w = list(a)
    h = list(b)
  else:
    w = list(b)
    h = list(a)
  for k in range(q):
    if w[k] in h:
      t += 1
  ans = max(ans,t)
print(ans)

n=int(input())
s = list(input())
wd = list("abcdefghijklmnopqrstuvwxyz")
ans=0
for i in range(n):
  s1 = set(s[:i])
  s2=set(s[i:])
  tmp=0
  for w in wd:
    if w in s1 and w in s2:
      tmp+=1
  ans=max(ans,tmp)
print(ans)


n = int(input())
s = input()
match = []
for i in range(1,len(s)):
    s1 = list(s[:i])
    s2 = list(s[i:])
    cnts = []
    for j in s1:
        if j in s2:
            if j not in cnts:
                cnts.append(j)
    match.append(len(cnts))
print(max(match))

n = int(input())
a = input()
dic="abcdefghijklmnopqrstuvwxyz"
maxcount = 0
for i in range(n):
  count = 0
  for j in range(26):
    if str(dic[j]) in a[:i] and str(dic[j]) in a[i:]:
      count+=1
  maxcount = max(count,maxcount)
print(maxcount)

n=int(input())
s=input()
alh="abcdefghijklmnopqrstuvwxyz"
max=0
for i in range(n):
  front=s[:i]
  rear=s[i:]
  cnt=0
  for j in alh:
    if j in front and j in rear:
      cnt+=1
  if cnt>max:
    max=cnt
print(max)

N = int(input())
S = input()

print(max([len(set(S[:i]) & set(S[i:])) for i in range(N)]))

n = int(input())
s = input()
a = []
for i in range(1, n):
  a.append(len(set(s[:i]) & set(s[i:])))
print(max(a))

# ABC098

N = int(input())
S = input()
ans = 0
for i in range(len(S)):
    left = set(S[0:i])
    right = set(S[i:len(S)])

    ans = max(ans, len(left & right))
print(ans)


n = int(input())
s = list(input())
ans = []
for i in range(1, n):
    first_falf = set(s[:i])
    after_falf = set(s[i:])
    count = 0
    for word in first_falf:
        if word in after_falf:
            count += 1
    ans.append(count)
print((max(ans)))


n = int(input())
s = str(input())
ans = 0

for i in range(1,n):
    l = list(s[0:i])
    r = list(s[i:n])
    dup = len(set(l)&set(r))

    if ans < dup:
        ans = dup
print(ans)


n = int(input())
s = list(map(str,input()))
ansl = []
for i in range(1,n):
  ans = 0
  x = list(set(s[:i]))
  y = list(set(s[i:]))
  for j in range(len(x)):
    if x[j] in y:
      ans += 1
  ansl.append(ans)
print(max(ansl))

n = int(input())
S = list(input())
ans = 0

for i in range(1,n-1):
  L = S[:i]
  R = S[i:]
  UL = set(L)
  UR = set(R)
  ans = max(ans, len(UL & UR))

print(ans)

N = int(input())
S = input()

r = 0
for i in range(1, N):
  s1 = S[:i]
  s2 = S[i:]
  r = max(len(set(s1) & set(s2)), r)

print(r)


n=int(input())
s=input()
shurui=[]
for i in range(len(s)-1):
  zenhan=s[0:i+1]
  kouhan=s[i+1:len(s)]
  kaburu=[]
  kaburu.clear()
  a=0
  for j in range(len(zenhan)):
    if kouhan.count(zenhan[j]) != 0 and kaburu.count(zenhan[j])==0:
      a+=1
      kaburu.append(zenhan[j])
  shurui.append(a)
print((max(shurui)))


_ = input()
S = input()

print(max(len(set(S[:i]) & set(S[i:])) for i in range(len(S))))

N = int(input())
s = input()

def count(x, y):
   l= []
   result = 0
   for i in range(len(x + y)):
      l.append((x + y)[i])
   for letter in set(l):
      if (letter in x) and (letter in y):
         result += 1
   return result

lst = []
for i in range(1, N):
   lst.append(count(s[:i], s[i:]))

print(max(lst))

N = int(input())
S = list(input())

print(max([len(set(S[:i]) & set(S[i:])) for i in range(N)]))

N = int(input())
S = input()

ss = []
for s in S:
    if s not in ss:
        ss.append(s)

max_count = 0
for i in range(1, N-1):
    count = 0
    for s in ss:
        x = S[0:i]
        y = S[i:N]
        if s in x and s in y:
            count += 1
    if count > max_count:
        max_count = count

print(max_count)

N=int(input())
S=input()

ans=0
for i in range(N):
    X=S[0:i]
    Y=S[i:N] 
    XY=set(X) & set(Y)
    cnt=len(XY)
    ans=max(ans,cnt)

print(ans)

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N = I()
    s = S()
    ans = 0
    for i in range(N):
        a = s[:i]
        b = s[i:]
        c = len(set(a).intersection(set(b)))
        ans = max(c, ans)
    print(ans)


main()



def answer(n: int, s: str) -> int:
    result = 0
    for i in range(1, n):
        x = set(s[i:])
        y = set(s[:i])
        common_characters = x.intersection(y)
        result = max(result, len(common_characters))

    return result

def main():
    n = int(input())
    s = input()
    print((answer(n,s)))

def __starting_point():
    main()

__starting_point()


N = int(input())
S = input()

ans = 0

for i in range(N-1):
    L = S[:i+1]
    R = S[i+1:]
    c = 0
    for l in set(L):
        if l in R:
            c += 1

    ans = max(ans, c)

print(ans)

def calc_intersection():
    n = int(input())
    s = input()
    list_intersection = []

    for i in range(1, n):
        a = set(s[:i])
        b = set(s[i:])
        intersection_a_b = a.intersection(b)
        list_intersection.append(len(intersection_a_b))
    return max(list_intersection)


def __starting_point():
    print(calc_intersection())
__starting_point()