Problem:
 Score : 200 points    Problem Statement 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 1 6
aabbca      Sample Output 1 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 .       Sample Input 2 10
aaaaaaaaaa      Sample Output 2 1  However we divide S , only a will be contained in both X and Y .       Sample Input 3 45
tgxgdqkyjzhyputjjtllptdfxocrylqfqjynmfbfucbir      Sample Output 3 9

Solution (Python):
n = int(input())
s = input()
ans = 0
find = []
for i in range(1, n):
    left  = s[:i]
    right = s[i:]
    cnt = 0
    find = []
    for c in left:
        if c in right and c not in find:
            cnt += 1
            find.append(c)
    if cnt > ans:
        ans = cnt
print(ans)

Solution (Python):
n = int(input())
s = input()
ans = 0
for i in range(1, n):
    tmp = 0
    dic = {}
    sl = list(set(s[:i]))
    sr = list(set(s[i:]))
    

    for c in sl:
        if c not in dic:
            dic[c] = 0

    for c in sr:
        if c in dic:
            tmp += 1
    ans = max(ans, tmp)
print(ans)

Solution (Python):
N = int(input())
S = input()

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

    ans = max(ans, len(set(list(S1)) & set(list(S2))))
print(ans)

Solution (Python):
def count(a,b):
  c = 0
  for i in set(a):
    if i in b:
      c += 1
  return c
n = int(input())
s = input()
lmax = 0
i = n-1
while i>=0:
  left = s[:i]
  right = s[i:]
  c = count(left,right)
  lmax = max(lmax,c)
  i-=1
print(lmax)

Solution (Python):
n = int(input())
s = input()

ANS = []
for i in range(n):
  p = 0
  A = set(s[0:i])
  B = set(s[i:n+1])
  for j in A:
    if j in B:
      p += 1
  ANS.append(p)
  
  
print(max(ANS))

Solution (Python):
N = int(input())
S = list(input())
maxCommon = 0
for i in range(1, N):
    count = 0
    for j in range(ord('a'), ord('z')+1):
        left = False
        right = False
        for k in range(i):
            if ord(S[k]) == j:
                left = True
        for k in range(N - 1, i - 1, -1):
            if ord(S[k]) == j:
                right = True
        if right and left:
            count += 1
    if maxCommon < count:
        maxCommon = count
print(maxCommon)

Solution (Python):
N = int(input())
S = list(input())
maxCommon = 0
for i in range(1, N):
    commonNum = len(list(set(S[0:i]) & set(S[i:])))
    if commonNum > maxCommon:
        maxCommon = commonNum
print(maxCommon)

Solution (Python):
n = int(input())
s = input()

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

print(ans)

Solution (Python):
N = int(input())
S = input()

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

Solution (Python):
N = int(input())
s = input()

maxx = 0

for i in range(N - 1):
    left = s[: i + 1]
    right = s[i + 1 :]
    
    and_LR = set(left) & set(right)
    cnt = len(and_LR)
    
    maxx = max(maxx, cnt)
    
print(maxx)

Solution (Python):
import collections

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

maxx = 0

for i in range(N - 1):
    left = s[: i + 1]
    right = s[i + 1 :]
    
    CNT_left = collections.Counter(left)
    CNT_right = collections.Counter(right)
    
    cnt = 0
    
    for k in CNT_left.keys():
        num = CNT_right[k]
        
        if (num >= 1):
            cnt += 1
    
    maxx = max(maxx, cnt)
    
print(maxx)

Solution (Python):
n = int(input())
s = list(input())
l = 0
for i in range(1,n-1):
  p = list(set(s[:i]))
  q = list(set(s[i:]))
  pq = set(p) & set(q)
  k = len(pq)
  if k>l:
    l=k
print(l)

Solution (Python):
N = int(input())
S = input()

abc = 'abcdefghijklmnopqrstuvwxyz'

ans = 0
for i in range(1, N):
  abcdict = {c:0 for c in abc}
  A = S[:i]
  B = S[i:]
  for ai in A:
    if ai in B:
      abcdict[ai] = 1
  now = 0
  for c in abc:
    now += abcdict[c]
  ans = max(ans, now)
  
print(ans)

Solution (Python):
n = int(input())
s = input()
ans = []
for i in range(1, n):
  x = set()
  y = set()
  for e in s[:i]:
    x.add(e)
  for e in s[i:]:
    y.add(e)
  ans.append(len(list(x & y)))
print(max(ans))

Solution (Python):
n=int(input())



s=list(input())
mx=0
for i in range(1,n):
    l1=s[0:i];l2=s[i:n]
    mx=max(mx,len(set(l1) & set(l2)))

print(mx)

Solution (Python):
n = int(input())
s = input()

re_ans = 0
for i in range(1, n):
    ans = 0
    lis = []
    t = s[:i]
    u = s[i:]
    for j in range(len(t)):
        if t[j] in u and t[j] not in lis:
            ans += 1
            lis.append(t[j])
        if re_ans < ans:
            re_ans = ans
print(re_ans)

Solution (Python):
n = int(input())
s = list(input())
l = 0
for i in range(1,n-1):
    p = list(set(s[:i]))
    q = list(set(s[i:]))
    pq = set(p) & set(q)
    k = len(pq)
    if k > l:
        l = k
print(l)

Solution (Python):
N = int(input())
S = input()
maxy= 0

for i in range(N-1):
    Sl = set(S[:i+1])
    Sr = set(S[i+1:])

    counter = 0
    for j in Sl:
        if j in Sr:
            counter += 1
    maxy = max(maxy, counter)
    
print(maxy)

Solution (Python):
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n=ni()
s=[_ for _ in input()]


mx=0

for i in range(n):
  sr =s[:i]
  sl = s[i:]
  r=set(sr)
  l=set(sl)

  nn=len(r & l)
  mx = max(nn,mx)

print(mx)

Solution (Python):
n = int(input())
s = input()

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

Solution (Python):
n = int(input())
s = list(input())
ans = 0
for i in range(1, n):
    x = s[:i]
    y = s[i:]
    temp = 0
    for ch in range(26):
        if chr(ch + 97) in x and chr(ch + 97) in y:
            temp += 1
    ans = max(ans, temp)
print(ans)

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

Solution (Python):
n=int(input())
s=input()
alp='abcdefghijklmnopqrstuvwxyz'

b=[]
for i in range(n):
  count=0
  s1=s[:i]
  s2=s[i:]
  for j in alp:
    if s1.count(j)*s2.count(j):
      count+=1
  b.append(count)
print(max(b))

Solution (Python):
n = int(input())
s = input()

max_c = 0

for i in range(1, n):
    part1 = s[:i]
    part2 = s[i:]

    intersection = set(part1) & set(part2)

    count_intersection = len(intersection)

    if count_intersection >= max_c:
        max_c = count_intersection

print(max_c)

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

Solution (Python):
n = int(input())
s = input()
l = list(s)
m = 0
for i in range(n - 1):
    l1 = l[:i+1]
    l2 = l[i+1:]
    l1 = list(set(l1))
    l2 = list(set(l2))
    l1.sort()
    l2.sort()
    x = 0
    for j in range(len(l1)):
        if l1[j] in l2:
            x += 1
    if x > m:
        m = x
print(m)

Solution (Python):
n=int(input())
s=input()
ans = 0
for i in range(1,n):
  a = set(list(s[:i]))
  b = set(list(s[i:]))
  c = a&b
  ans = max(ans,len(c))
print (ans)

Solution (Python):
n = int(input())
s = list(input())

ans = 0

for a in range(1, n):
    x = len(set(s[:a]) & set(s[a:]))
    ans = max(ans, x)

print(ans)

Solution (Python):
n = int(input())
s = input()

s = list(s)
ans = 0
count = 0

for a in range(1, n):
    l1 = list(set(s[:a]))
    l2 = set(s[a:])

    length1 = len(l1)

    for x in range(length1):
        if l1[x] in l2:
            count += 1
    ans = max(ans, count)
    count = 0

print(ans)

Solution (Python):
n = int(input())
s = input()

s = list(s)
ans = 0
count = 0

for a in range(1, n):
    l1 = list(set(s[:a]))
    l2 = list(set(s[a:]))

    length1 = len(l1)

    for x in range(length1):
        if l1[x] in l2:
            count += 1
    ans = max(ans, count)
    count = 0

print(ans)

Solution (Python):

import math


def inp():
    return(int(input()))



def inlist():
    return(list(map(int, input().split())))



def instr():
    s = input()
    return(list(s[:len(s)]))



def invr():
    return(map(int, input().split()))


def coutDiffL(a1, a2):
    a1 = set(a1)
    a2 = set(a2)
    a3 = a1.intersection(a2)
    return len(a3)


n = inp()

s = input()
res = 0
for i in range(1, n-1):
    m1 = coutDiffL(s[:i], s[i:])
    if m1 > res:
        res = m1


print(res)

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

Solution (Python):
n=int(input())
s=input()
ans=0
ans_index=0
for i in range(n):
  ans_index=0
  Left=s[0:i]
  Right=s[i:]
  
  
  if (Left.count("a")>0 and Right.count("a")>0):
    ans_index+=1
  if (Left.count("b")>0 and Right.count("b")>0):
    ans_index+=1
  if (Left.count("c")>0 and Right.count("c")>0):
    ans_index+=1
  if (Left.count("d")>0 and Right.count("d")>0):
    ans_index+=1
  if (Left.count("e")>0 and Right.count("e")>0):
    ans_index+=1
  if (Left.count("f")>0 and Right.count("f")>0):
    ans_index+=1
  if (Left.count("g")>0 and Right.count("g")>0):
    ans_index+=1
  if (Left.count("h")>0 and Right.count("h")>0):
    ans_index+=1
  if (Left.count("i")>0 and Right.count("i")>0):
    ans_index+=1
  if (Left.count("j")>0 and Right.count("j")>0):
    ans_index+=1
  if (Left.count("k")>0 and Right.count("k")>0):
    ans_index+=1
  if (Left.count("l")>0 and Right.count("l")>0):
    ans_index+=1
  if (Left.count("m")>0 and Right.count("m")>0):
    ans_index+=1
  if (Left.count("n")>0 and Right.count("n")>0):
    ans_index+=1
  if (Left.count("o")>0 and Right.count("o")>0):
    ans_index+=1
  if (Left.count("p")>0 and Right.count("p")>0):
    ans_index+=1
  if (Left.count("q")>0 and Right.count("q")>0):
    ans_index+=1
  if (Left.count("r")>0 and Right.count("r")>0):
    ans_index+=1
  if (Left.count("s")>0 and Right.count("s")>0):
    ans_index+=1
  if (Left.count("t")>0 and Right.count("t")>0):
    ans_index+=1
  if (Left.count("u")>0 and Right.count("u")>0):
    ans_index+=1
  if (Left.count("v")>0 and Right.count("v")>0):
    ans_index+=1
  if (Left.count("w")>0 and Right.count("w")>0):
    ans_index+=1
  if (Left.count("x")>0 and Right.count("x")>0):
    ans_index+=1
  if (Left.count("y")>0 and Right.count("y")>0):
    ans_index+=1
  if (Left.count("z")>0 and Right.count("z")>0):
    ans_index+=1
  
  ans=max(ans,ans_index)
print(ans)

Solution (Python):
N=int(input())
S=input()
ans=0
for i in range(1,N+1):
    count=0
    for s in set(S[:i]):
        if s in S[i:]:
            count+=1
    ans=max(ans,count)
print(ans)

Solution (Python):
n=int(input())
s=input()
li=[]
for i in range(n):
    li.append(s[i])
num=[]
m=0
for i in range(1,n):
    l1=set(li[:i])
    l2=set(li[i:])
    for j in l1:
        if j in l2:
            m+=1
        else:
            pass
    num.append(m)
    m=0

ans=max(num)
print(ans)

Solution (Python):
import collections

n = int(input())
s = input()
l1 = []
l2 = []
ans = 0
for i in range(1,n):
  l1 = set(list(s[0:i:]))
  l2 = set(list(s[i::]))
  ans = max(ans,len(l1&l2))

  
print(ans)

Solution (Python):
n = int(input())
s = input()


def cnt(s, k):
    s1 = set(s[:k])
    s2 = set(s[k:])
    return len(s1.intersection(s2))

ans = 0
for i in range(n):
    ans = max(ans, cnt(s, i))
print(ans)

Solution (Python):
N = int(input())
S = input()

ans = 0
for n in range(1,N):
  ans_candidate = len(set(S[:n])&set(S[n:]))
  if ans_candidate > ans:
    ans = ans_candidate
print(ans)

Solution (Python):
from collections import Counter
n = int(input())
ltr = input()

res = 0
for i in range(n):
    s = Counter(ltr[:i]) & Counter(ltr[i:])
    res = max(res, len(s))
print(res)

Solution (Python):
n = int(input())
s = input()

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

Solution (Python):
n=int(input())
s=input()
ans=0
for i in range(1,n):
    count=0
    str1=set(s[:i])
    str2=s[i:]
    for j in range(len(str1)):
        str3=(str1.pop()) in str2
        if str3==True:
            count+=1
    if ans<count:
        ans=count
print(ans)

Solution (Python):
N = int(input())
S = list(input())
ans = 0
for i in range(N):
  A = S[:i]
  B = S[i:]
  C = list(set(A) & set(B))
  
  c = len(C)
  if c > ans:
    ans += 1

print(ans)

Solution (Python):
n=int(input())
s=input()
ans=0
for i in range(1,n-1):
    X=s[:i]
    Y=s[i:]
    c=0
    a=list(set(X))
    
    for j in range(len(a)):
        if a[j] in Y:
            c+=1
    if c>ans:
        ans=c
print(ans)

Solution (Python):
n = int(input())
S = input()

idx = n//2
x = S[:idx]
y = S[idx:]
if x == y:
    print(1)
    exit()

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

    x = S[:idx+i]
    y = S[idx+i:]
    cs = max(cs, len(set(x) & set(y)))

print(cs)

Solution (Python):
N = int(input())
S = list(input())
ans = 0

for i in range(N):
    A = set(S[:i+1])
    B = set(S[i+1:])
    s = list(A & B)
    ans = max(ans, len(s))

print(ans)

Solution (Python):
N = int(input())
S = input()
ans = 0
for i in range(1, N):
    X = set(S[:i])
    Y = set(S[i:])
    ans = max(ans, len(X.intersection(Y)))
print(ans)

Solution (Python):

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

print(ans)

Solution (Python):

import sys
input = sys.stdin.readline









N = int(input())
S = input().rstrip()

ans = 0
for i in range(1,N):
    l,r = set(),set()
    for s in S[:i]:
        l.add(s)
    for s in S[i:]:
        r.add(s)
    ans = max(ans,len(l&r))

print(ans)

Solution (Python):
n = int(input())
s = input()
count = 0
for i in range(n):
	count = max(count, len(set(s[:i]) & set(s[i:])))
print(count)

Solution (Python):
import sys
from collections import Counter
from collections import deque
import math
import fractions
import bisect
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))


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

Solution (Python):
N = int(input())
s=list(input())
ans=0
for i in range(1,N-1):
  tmp=set(s[:i]) & set(s[i:])
  kari=len(tmp)
  if ans<kari:
    ans=kari
print(ans)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
S = input()

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

print(ans)

Solution (Python):
N = int(input())
S = list(input())
ans = 0
for i in range(N):
  A = S[:i]
  B = S[i:]
  C = list(set(A) & set(B))
  c = len(C)
  if c > ans:
    ans += 1



print(ans)

Solution (Python):

import sys
sys.setrecursionlimit(10000000)
INF = 1 << 32


def solve(N: int, S: str):
    m = 0
    for i in range(1, N - 1):
        m = max(m, len(set(list(S[:i])) & set(list(S[i:]))))
    print(m)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    S = next(tokens)  
    solve(N, S)


if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
S = input().strip()
cmax = 0
for n in range(1,N-1):
    X = S[:n]
    Y = S[n:]
    Cx = {}
    Cy = {}
    for i in range(n):
        a = X[i]
        if a not in Cx:
            Cx[a] = 0
        Cx[a] += 1
    for i in range(N-n):
        a = Y[i]
        if a not in Cy:
            Cy[a]=0
        Cy[a] += 1
    cnt = 0
    for a in Cx:
        if a in Cy:
            cnt += 1
    cmax = max(cmax,cnt)
print(cmax)

Solution (Python):
N = int(input())
S = input()

ans = 0

for i in range(1,N-1):
    l = set()
    count = 0
    for j, s in enumerate(S):
        if j < i:
            l.add(s)
        else:
            if s in l:
                count += 1
                l.discard(s)
    ans = max(ans, count)
print(ans)

Solution (Python):
n = int(input())
S = input()
from collections import Counter
ans = 0
for i in range(1,n):
    f = S[:i]
    b = S[i:]
    f = set(f)
    
    
    cnt = 0
    for v in f:
        
        if v in b:
            cnt += 1
    ans = max(ans,cnt)
print(ans)

Solution (Python):
n = int(input())
s = str(input())
ans = -1
for i in range(1, n):
    x = s[0:i]
    y = s[i:]
    temp = 0
    for j in range(26):
        c = chr(ord('a')+j)
        if c in x and c in y:
            temp += 1
    ans = max(ans, temp)
print(ans)

Solution (Python):
import sys
input = sys.stdin.readline
from collections import *

N = int(input())
S = input()[:-1]
ans = 0

for i in range(N+1):
    sx = set()
    
    for j in range(i):
        sx.add(S[j])
    
    sy = set()
    
    for j in range(i, N):
        sy.add(S[j])
    
    ans = max(ans, len(sx&sy))

print(ans)

Solution (Python):
import sys
input = sys.stdin.readline

n = int(input())
s = input().rstrip()

ans = -1

for i in range(n):
    x = s[:i]
    y = s[i:]
    z = set()
    res = 0
    for j in range(len(x)):
        if y.count(x[j]) >= 1 and x[j] not in z:
            res += 1
            z.add(x[j])
    ans = max(ans, res)
print(ans)

Solution (Python):
n = int(input())
s = input()

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

Solution (Python):
n = int(input())
s = input()

cnt = 0
for i in range(1,n):
  x = s[:i]
  y = s[i:]
  xy = set(x)&set(y)
  if cnt < len(xy): cnt = len(xy)
print(cnt)

Solution (Python):
n = int(input())
s = list(input())
ans = 0
for i in range(1, n-1):
    x = set(s[:i])
    y = set(s[i:])
    cnt = 0
    for c in x:
        if c in y:
            cnt += 1
    if cnt > ans:
        ans = cnt

print(ans)

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

Solution (Python):
N = int(input())
S = list(input())
cnt = []
for i in range(0,N):
    s1 = set(S[0:i])
    s2 = set(S[i:])
    cnt.append(len(list(s1 & s2)))
print(max(cnt))

Solution (Python):
N=int(input())
S=input()
ans=0
for i in range(N):
  s = set(S[:i])
  s = list(s)
  count=0
  for j in range(len(s)):
    if s[j] in S[i:]:
      count+=1
  ans = max([ans, count])
print(ans)

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

Solution (Python):
n = int(input())
s = input()

cs = [0]*(n-1)

for i in range(n-1):
    cnt = 0
    memo = []
    for j in s[0:i+1]:
        if j in s[i+1:n] and j not in memo:
            cnt += 1
        memo.append(j)
        
    cs[i] = cnt

print(max(cs))

Solution (Python):
n = int(input())
s = input().strip()

mx = 0
for i in range(len(s)):
    first = set(list(s[:i + 1]))
    second = set(list(s[i + 1:]))

    intersection = first & second
    mx = max(len(intersection), mx)

print(mx)

Solution (Python):

def main():
    N = int(input()) 
    S = input() 
    maxv = 0
    for i in range(1,N-1):
        x = S[0:i]
        y = S[i:N]
        xl = list(set(x))
        yl = list(set(y))
        cnt = 0
        for xx in xl:
            cnt += yl.count(xx)
        maxv = max(maxv,cnt)
    
    print(maxv)






if __name__ == '__main__':
    main()

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

Solution (Python):
N = int(input())
S = list(input())

result = 0
for i in range(N):
    num = set(S[0:i+1]) & set(S[i+1:N])
    
    result = max(result, len(num))
print(result)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
S = input()

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

print(ans)

Solution (Python):
N=int(input())
S=list(str(input()))

max_match=0
for i in range(1,N):
  match=0
  left=set(S[:i])
  right=set(S[i:])
  for j in left:
    if j in right:
      match+=1
  if match > max_match:
    max_match=match
print(max_match)

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    def main():
        n=int(input())
        s=input()
        sset=set(s)
        ans=0
        for i in range(1,n):
            x=s[:i]
            y=s[i:]
            cnt=0
            for j in sset:
                if j in x and j in y:
                    cnt+=1
                    if cnt==len(sset):
                        return cnt
            ans=max(ans,cnt)
        return ans
    print(main())
resolve()

Solution (Python):


import sys





import string                                
























def main():
    mod = 1000000007                
    inf = float('inf')              
    
    sys.setrecursionlimit(10**6)    
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    def calc_common_char_nums(a, b):
        set_a, set_b = set(list(a)), set(list(b))    
        cnt = 0
        for char in string.ascii_lowercase:
            if char in set_a and char in set_b:
                cnt += 1
        return cnt



    n = ii()
    s = input()
    ans = -1
    for i in range(1, n):
        a, b = s[:i], s[i:]
        ans = max(ans, calc_common_char_nums(a, b))
    
    print(ans)



if __name__ == "__main__":
    main()

Solution (Python):
n=int(input())
s=input()
ans=0
anss=0
for i in range(1,n):
    migi=list(set(list(s[:i])))
    hidari=list(set(list(s[i:])))
    for j in migi:
        if j in hidari:
            anss+=1
    ans=max(ans,anss)
    anss=0
print(ans)

Solution (Python):
N  = int(input())
S = list(input())
D = [0]*(N-1)
for i in range(1, N):
  A = S[:i]
  B = S[i:]
  A1 = set(A)
  B1 = set(B)
  C = A1 & B1
  D[i-1] = len(C)
print(max(D))

Solution (Python):
N = int(input())
S = input()

ans = 0
for i in range(N):
    a = S[:i]
    b = S[i:]
    c = set(list(a)) & set(list(b))
    ans = max(ans, len(c))

print(ans)

Solution (Python):
N = int(input())
S = input()
ans = 0
for i in range(N):
    cnt = 0
    X = set(S[:i])
    Y = set(S[i:])
    for j in X:
        if j in Y:
            cnt += 1
    ans = max(ans, cnt)
print(ans)

Solution (Python):
N = int(input())
S = input()
ans = 0
for i in range(N):
    cnt = 0
    X = set(S[:i])
    Y = set(S[i:])
    for j in X:
        if j in Y:
            cnt += 1
    ans = max(ans, cnt)
print(ans)

Solution (Python):
N = int(input())
S = list(input())
answer = 0

for i in range(1, N):
    count = 0
    front = list(set(S[:i]))
    back = list(set(S[i:]))
    F = len(front)
    for j in range(F):
        count += back.count(front[j])
    if count>answer:
        answer = count
print(answer)

Solution (Python):
from collections import Counter
n = int(input())
s = input()
ma = 0
for i in range(1,n):
    s1=s[:i]
    s2=s[i:]
    common = set(s1) & set(s2)
    ma = max(ma,len(common))
print(ma)

Solution (Python):
n = int(input())
s = input()
count = 0
ans = 0
x,y = '',''

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

Solution (Python):
N = int(input())
S = str(input())
arr = []
cnt = 0

for i in range(1,N):

  for ch in range (97,123):
    if S[:i].count(chr(ch)) != 0 and S[i:].count(chr(ch)) != 0:
      cnt=cnt+1
  arr.append(cnt)
  cnt=0

print(max(arr))

Solution (Python):
N = int(input())
S = list(input())
MAX = 0
for i in range(N):
    MAX = max(MAX,len(set(S[:i]) & set(S[i:])))
print(MAX)

Solution (Python):
n = int(input())
s = input()

ans = 0
for i in range(1, n):
    s1 = set(list(s[: i]))
    s2 = set(list(s[i :]))
    tmp = len(list(s1 & s2))
    ans = max(ans, tmp)
    
print(ans)

Solution (Python):
n=int(input())
s=input()

ans=0
for i in range(n):
    sl=set()
    sr=set()
    for j in range(n):
        if j<=i:
            sl.add(s[j])
        else:
            sr.add(s[j])
    ans=max(ans,len(sl & sr))
print(ans)

Solution (Python):
n = int(input())
s = input()

ans = 0
for i in range(1, n):
    cur = 0
    a = set(s[:i])
    b = set(s[i:])
    for A in a:
        if A in b:
            cur += 1
    ans = max(ans, cur)
print(ans)

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

Solution (Python):
n = int(input())
s = input()

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

Solution (Python):
n=int(input())
s=input()
ans=[]
for i in range(n):
    ans.append(len(set((s[:i]))&(set(s[i:]))))
print(max(ans))

Solution (Python):

n = int(input())
s = input()
ans = 0
for i in range(1,n):
    a = 0
    sx = set(s[i:])
    sy = set(s[:i])
    for sxi in sx:
        if sxi in sy:
            a+=1
    ans = max(ans,a)
print(ans)

Solution (Python):
import sys

readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

N = int(readline().rstrip().decode("utf-8"))
S = readline().rstrip().decode("utf-8")

ans = 0
for i in range(N-1):
    left = S[:i+1] 
    right = S[i+1:]
    

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

Solution (Python):

n=int(input())
s=input()
ans=0
for i in range(n):
    a=set(s[:i]);b=set(s[i:])
    c= a&b
    ans=max(ans,len(c))
print(ans)

Solution (Python):
n = int(input())
s = input()

ans = 0
for i in range(1,n):
  x = s[:i]
  y = s[i:]
  
  tmp = 0
  for each in list(set(x)):
    if each in set(y):
      tmp += 1
  
  ans = max(ans, tmp)
  
print(ans)

Solution (Python):
n = int(input())
s = input()
ans = 0
for i in range(1, n):
  t = s[0:i]
  t2 = s[i:n]
  t = list(set(t))
  t2 = list(set(t2))
  cnt = 0
  for j in t:
    if j in t2:
      cnt += 1
  ans = max(ans, cnt)
print(ans)

Solution (Python):
N = int(input())
S = input()

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

Solution (Python):
n=int(input())
s=input()
t=""
k=""
l=[]
for i in range(1,n):
    ans1=0
    t=sorted(set(s[:i]))
    k=sorted(set(s[i:]))
    for i in t:
        for j in k:
            if i==j:
                ans1+=1
    l.append(ans1)
print(max(l))

Solution (Python):
n=int(input())
s=input()
t=""
k=""
ans=0
l=[]
for i in range(1,n):
    ans1=0
    t=sorted(set(s[:i]))
    k=sorted(set(s[i:]))
    for i in t:
        for j in k:
            if i==j:
                ans1+=1
    l.append(ans1)
print(max(l))

Solution (Python):
n=int(input())
s=input()
t=""
k=""
ans=0
l=[]
for i in range(1,n):
    ans1=0
    t=sorted(set(s[:i]))
    k=sorted(set(s[i:]))
    for i in t:
        for j in k:
            if i==j:
                ans1+=1
            l.append(ans1)
print(max(l))

Solution (Python):
n=int(input())
s=list(input())

a=set(s)
ans=0
for i in range(len(s)-1):
    l=set(s[:i+1])
    r=set(s[i+1:])
    d=len(l)+len(r)-len(a)
    if d>ans:
        ans=d
print(ans)

Solution (Python):






import sys
input = sys.stdin.readline

import math

import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache






MOD = 10**9+7
INF = float('inf')






def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]


def Yes(): print("Yes"); return
def No(): print("No"); return


def inv(n): return pow(n, MOD-2, MOD)


kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr


def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors


def lcm(a, b):
    return a * b // gcd (a, b)


def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count


def Base_10_to_n(X, n):
  if (int(X/n)):
    return Base_10_to_n(int(X/n), n)+[X%n]
  return [X%n]






N = inputI()
S = inputS()

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

Solution (Python):
N = int(input())
S = input()

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