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()
res= 0
for i in range(n-1):
    tres= 0
    x = s[:i+1]
    y = s[i+1:]
    l=[]
    for c in x:
        if not (c in l) and (c in y):
            l.append(c)
            tres += 1
    res = max(res,tres)

print(res)

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

max_count = 0  
for i in range(N):
  l = S_list[i:]
  cs = set(S_list[0:i])
  
  count = 0
  for s in cs:
    if s in l:
      count += 1
    if count > max_count:
      max_count = count
print(max_count)

Solution (Python):
n=int(input())
a=input()
cnt=0
for i in range(n-1):
    seta=set(a[:i+1])
    setb=set(a[i+1:])
    tmp=len(seta&setb)
    cnt=max(cnt,tmp)
print(cnt)

Solution (Python):
import collections
n = int(input())
S = 0
s = input()
maximum = 0
for i in range(n):
  l = s[:i]
  r = s[i:]
  c = collections.Counter(l)
  c = c.most_common()
  for j in range(len(c)):
    if c[j][0] in r:
      S += 1
  maximum = max(maximum,S)
  S = 0
print(maximum)

Solution (Python):
import string

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

ans = 0

for i in range(1, N):
    cnt = 0
    for j in string.ascii_lowercase:
        if j in S[:i] and j in S[i:]:
            cnt += 1
    if cnt > ans:
        ans = cnt

print(ans)

Solution (Python):
n = int(input())
s = input()
ans = 0
for i in range(n):
    ctn = 0
    x = set(s[:i])
    y = set(s[i:])
    for j in x:
        if j in y:
            ctn += 1
    if ans < ctn:
        ans = ctn
print(ans)

Solution (Python):
N = int(input())
S = list(input())
counter = 0
for i in range(N):
    syu = len(set(S[:i]) & set(S[i:]))
    counter = syu if syu > counter else counter

print(counter)

Solution (Python):
n = int(input())
line = input()
a = []
b = []
max = 0

for i in range(0, n):
  a.clear()
  b.clear()
  for j in range(0, i):
  	a.append(line[j])
  for k in range(i, n):
    b.append(line[k])
    
  if (len(set(a) & set(b)) > max):
    max = len(set(a) & set(b))

print(max)

Solution (Python):
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

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

N=one_int()
S=one_str()

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

print(maxs)

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

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

main()

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

Solution (Python):



import sys













def main():
    n = int(sys.stdin.readline().rstrip())
    s = sys.stdin.readline().rstrip()

    max_count = 0
    for i in range(1, n):
        s1, s2 = s[:i], s[i:]
        count = 0
        for l in set(s1):
            if l in s2:
                count += 1
        max_count = max(count, max_count)
    
    print(max_count)





if __name__ == "__main__":
    
    main()

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


def main():
    N = int(input())
    S = input().strip()
    ma = 0
    for i in range(1, len(S)-1):
        ma = max(ma, len(set(S[:i]) & set(S[i:])))
    print(ma)


if __name__ == '__main__':
    main()

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

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
s = input()
res = 0
for i in range(n):
    cnt = 0
    d1 = defaultdict(int)
    d2 = defaultdict(int)
    for j in range(0,i):
        d1[s[j]] += 1
    for j in range(i,n):
        d2[s[j]] += 1
    for key in d1.keys():
        if d2[key] > 0:
            cnt += 1
    res = max(res, cnt)
print(res)

Solution (Python):
n=int(input())
s=input()
hsh1,hsh2 = [0]*26,[0]*26

hsh1[ord(s[0])-97]+=1
for i in range(1,n):
    hsh2[ord(s[i])-97]+=1
ans=0
ct=0
for i in range(26):
    if(hsh1[i]!=0 and hsh2[i]!=0):
        ct+=1
ans = max(ans,ct)

for i in range(1,n-1):
    ct=0
    cur = ord(s[i])-97
    hsh2[cur]-=1
    hsh1[cur]+=1
    for j in range(26):
        if(hsh1[j]!=0 and hsh2[j]!=0):
            ct+=1
    ans = max(ans,ct)
print(ans)

Solution (Python):
import collections
N = int(input())
Y = list(input())
X = []
ans = 0
for n in range(N):
    X.append(Y.pop(0))
    X_and_Y = set(X) & set(Y)
    ans = max(ans,len(X_and_Y))
print(ans)

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

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

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


def main():
    N = int(input())
    S = list(input()[:-1])

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


if __name__ == '__main__':
    main()

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

ans = 0
s1 = ''
s2 = ''

for i in range(1, n):
    s1 = set(s[:i])
    s2 = set(s[i:])
    tmp = 0
    for c in s1:
        if(c in s2):
            tmp += 1
    if(ans < tmp):
        ans = tmp

print(ans)

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

cnt_max = 0
for i in range(N):
    cnt = len(set(S[:i])&set(S[i:]))
    if cnt > cnt_max:
        cnt_max = cnt

print(cnt_max)

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

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

print(ans)

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

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

for i in range(1, n):
    pre = set(s[:i])
    post = set(s[i:])
    n = len(pre & post)
    if n > ans:
        ans = n

print(ans)

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

for i in range(N):
    sl = set()
    sr = set()

    for j, char in enumerate(S):
        if j <= i:
            sl.add(char)
        else:
            sr.add(char)
    
    if len(sl & sr) > max_kind:
        max_kind = len(sl & sr)

print(max_kind)

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

Solution (Python):
from string import ascii_lowercase

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

ans = -1
for mid in range(1, 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)

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

ans=0
for i in range(n):
    x=s[:i]
    y=s[i:]
    c=set(x)&set(y)
    if len(c) >= ans:
        ans=len(c)

print(ans)

Solution (Python):
import string

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

ans = 0
for n in range(1, N):
  counts = 0
  for c in string.ascii_lowercase:
    if c in S[:n] and c in S[n:]:
      counts += 1
  ans = max(counts, ans)
print(ans)

Solution (Python):
n = int(input())
s = str(input())
s = [str(si) for si in s]
ans = [0 for _ in range(n)]
for i in range(1, n):
    sp = s[:i]
    sp.sort()
    ss = s[i:]
    tmp = ""
    for j in sp:
        if j == tmp: continue
        else:
            if j in ss:
                ans[i] += 1
                tmp = j
print(max(ans))

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

m = 0
for i in range(1, n - 1):
  a = s[:i]
  b = s[i:]
  c = len(set(a) & set(b))
  if c >= m:
    m = c

print(m)

Solution (Python):
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)

Solution (Python):
import sys



def cc(sa, sb):
	aa=set(list(sa))
	bb=list(set(list(sb)))
	count=0
	for c in bb:
		if c in aa:
			count+=1
	return count


def main():
	n=int(input())
	s=input()
	ans=0
	for i, _ in enumerate(s):
		ans=max(ans, cc(s[:i], s[i:]))
	
	print(ans)
	
	

isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		
			
	ret = main()
	if ret is not None:
		print(ret)

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

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

Solution (Python):
n = int(input())
s = input()
max = 0
for i in range(n):
  c = 0
  for j in set(s[:i]):
    if j in set(s[i:]):
      c += 1
  if c > max:
    max = c
print(max)

Solution (Python):
N = int(input())
S = input()
count = 0
for i in range(N):
    tmpcount = 0
    tmp1 = list(set(S[:i]))
    tmp2 = list(set(S[i:]))
    for j in range(len(tmp1)):
        if tmp1[j] in tmp2:
            tmpcount += 1
    if tmpcount >= count:
        count = tmpcount
print(count)

Solution (Python):
N = int(input())
S = input()
ans = -float('inf')
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()
max_count = 0
for i in range(1,n):
    left_s = set(list(s[:i]))
    right_s = set(list(s[i:]))
    temp = left_s & right_s
    if max_count < len(temp):
        max_count = len(temp)
print(max_count)

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

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

Solution (Python):

N, S = open(0).readlines()
S = list(S)


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

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

max_kinds = 0
for i in range(N):
  kinds = len(set(S[:i]) & set(S[i:]))
  if kinds > max_kinds:
    max_kinds = kinds
    
print(max_kinds)

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

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

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

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
    for c in set(s[:i]):
        if c in set(s[i:]):
            count += 1
    if ans < count:
        ans = count
print(ans)

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

minind={}
maxind={}

for i,c in enumerate(S):
    if c not in minind:
        minind[c]=i
    maxind[c]=i

cnt=[0 for i in range(N+1)]

for c in [chr(i) for i in range(97,97+26)]:
    if c in minind and minind[c]<maxind[c]:
        for j in range(minind[c]+1,maxind[c]+1):
            cnt[j]+=1

print(max(cnt))

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

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

def f(x, y):
  a = 0
  for i in range(97, 97+26):
    k = chr(i)
    if k in x and k in y:
      a += 1
  return a

a = 0
for i in range(1, n-1):
  a = max(a, f(s[:i], s[i:]))
print(a)

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

Solution (Python):
N=int(input())
S=[str(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()
ans=0
c=0
for i in range(n):
    c=len(list(set(s[:i])&set(s[i:])))
    ans=max(ans,c)
print(ans)

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

def mojisu(s1, s2):
    c = collections.Counter(s1)
    cnt = 0
    for c in c.keys():
        if c in s2:
            cnt += 1
    return cnt

m = 0
for i in range(1,N):
    _ = mojisu(S[:i], S[i:])
    if m < _:
        m = _
print(m)

Solution (Python):
N=int(input())
S=input()
t=N+1
ans=0

for s in range(1,t):
    a=set(S[0:s])
    b=set(S[s:])
    cnt=0
    for chr in a:
        if chr in b:cnt+=1
    if cnt>ans: ans=cnt
print(ans)

Solution (Python):
import string

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

ans = 0

for i in range(1, N):
    cnt = 0
    for j in string.ascii_lowercase:
        if j in S[:i] and j in S[i:]:
            cnt += 1
    if cnt > ans:
        ans = cnt

print(ans)

Solution (Python):
import collections
n = int(input())
s = [i for i in input()]
m = 0
for i in range(1,n):
    x = s[0:i]
    y = s[i:n]
    c1 = collections.Counter(x)
    c2 = collections.Counter(y)
    d1 = set(c1.keys())
    d2 = set(c2.keys())
    e = list(d1 & d2)
    m = max(m,len(e))
print(m)

Solution (Python):
n = int(input())
s = list(input())
kk = 0
for i in range(1,n):
  af = set(s[:i])
  bf = set(s[i:])
  if(kk < len(af & bf)):
    kk = len(af & bf)
print(kk)

Solution (Python):
def retNumOfCommonCharacters(left: str, right: str) -> int:
    cnt = 0
    for l in left:
        if l in right:
            cnt += 1

    return cnt

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

ans = 0
for i in range(1, n):
    num = retNumOfCommonCharacters(set(s[0:i]), set(s[i:]))
    if ans <= num:
        ans = num

print(ans)

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

    ans = 0
    for i in range(1, n):
        count = 0
        left = s[:i]
        right = s[-(n - i):]
        left_set = list(set(left))
        right_set = list(set(right))

        if left_set >= right_set:
            for j in range(len(right_set)):
                if right_set[j] in left_set:
                    count += 1
        else:
            for k in range(len(left_set)):
                if left_set[k] in right_set:
                    count += 1

        ans = max(count, ans)

    print(ans)


if __name__ == '__main__':
    cut_and_count()

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

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

Solution (Python):
import string

N = int(input())
S = input()
cnt = 0
for i in range(1, N):
  s1 = S[:i]
  s2 = S[i:]
  tmp = 0
  for j in string.ascii_lowercase:
    if j in s1 and j in s2:
      tmp += 1
  cnt = max(cnt, tmp)
print(cnt)

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

cnt = 0

for i in range(1, len(s) - 1):
    int_cnt = len(set(s[:i]) & set(s[i:]))
    if int_cnt > cnt:
        cnt = int_cnt

print(cnt)

Solution (Python):
n=int(input())
s=input()
c=[]
for i in range(n-1):
    a=s[:i]
    b=s[i:]
    c.append(set(a)&set(b))

d=[]
for i in range(len(c)):
    d.append(len(c[i]))
print(max(d))

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:]))
    ans = max(ans, len(a & b))

print(ans)

Solution (Python):
n=int(input())
s=input()
ans,d,e=0,0,0
for i in range(1,n-1):
  d=set(list(s[:i]))
  e=set(list(s[i:]))
  x=d.intersection(e)
  ans=max(ans,len(x))
print(ans)

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

tmp_list = []
for i in range(1,N):
    S1 = S[:i]
    S2 = S[i:]
    tmp_list.append(len(set(S1)&set(S2)))

print(max(tmp_list))

Solution (Python):


def resolve():
    input()
    s=[i for i in input()]

    mx=0
    for i in range(len(s)):
        A=set(s[:i])
        B=set(s[i:])
        AB=list(A & B)

        mx=max(mx,len(AB))
    print(mx)

if __name__ == "__main__":
    resolve()

Solution (Python):
N = int(input())
s = list(input())
result = 0

for i in range(N):
  result = max(result, len(set(s[:i]) & set(s[i:])))

print(result)

Solution (Python):
N = int(input())
S = list(input())
max_count = 0
for i in range(1, N-1):
    ans = []
    cnt = 0
    for j in S[:i]:
        if j not in ans and j in S[i:]:
            ans.append(j)
            cnt += 1
    if cnt > max_count:
        max_count = cnt

print(max_count)

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

max_len = 0

for i in range(1, n+1):
  l = set(s[:i])
  r = set(s[i:])
  
  if max_len < len(l&r): max_len = len(l&r)
    
print(max_len)

Solution (Python):
len = int(input())
ret = input()
count_max = 0
for i in range(1, len):
  count = 0
  for k in range(97, 123):
    if ((chr(k) in ret[:i]) and (chr(k) in ret[i:])):
      count += 1
  if count > count_max:
    count_max = count
print(count_max)

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

Solution (Python):
n = int(input())
k = list(x for x in input())
ans = [0] * n
for i in range(n):
  l = []
  for j in range(0,i):
    if l.count(k[j]) == 0:
      l.append(k[j])
      if k[i:n].count(k[j]) > 0:
        ans[i] += 1
print(max(ans))

Solution (Python):
import copy
n=int(input())
s=list(input())
x=[]
y=copy.copy(s)
num=0
for i in range(n):
    x+=[s[i]]
    y.pop(0)
    if len(set(x)&set(y))>num:
        num=len(set(x)&set(y))
    
print(num)

Solution (Python):
import collections
n=int(input())
s=input()
max=0
for i in range(1,n):
    cnt=0
    x = set(s[:i])
    y = set(s[i:])
    for item in x:
        if item in y:
            cnt += 1
    if cnt > max:
        max = cnt
print(max)

Solution (Python):
n = int(input())
s = list(input())
output = 0
count = 0

for i in range(1, n):
    x = set(s[0:i:])
    y = set(s[i::])
    count = 0
    for k in x:
        for l in y:
            if k == l:
                count += 1

    if count > output:
        output = count

print(output)

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

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

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

Solution (Python):
import collections
N=int(input())
S =input()
def countchar(s1,s2):
  ret=0
  table=collections.defaultdict(int)
  for x in s1:
    table[x]+=1
  for x in s2:
    if x in table and table[x]>0:
      ret+=1
      table[x]=0
  return(ret)
ans=0
for i in range(1,N):
  X=S[:i]
  Y=S[i:]
  ans=max(ans,countchar(X,Y))
print(ans)

Solution (Python):
import string
n=int(input())
s=list(input())
cnt=[0 for i in range(n-1)]
for i in range(n-1):
    for j in string.ascii_lowercase:
        if (j in s[:i+1] and j in s[i+1:]): cnt[i]+=1
print('{0}'.format(max(cnt)))

Solution (Python):
n=int(input())
s=input()
ans=0
for i in range(n-1):
    left=set([])
    right=set([])
    for x in range(n):
        if x <= i :
            left.add(s[x])
        else:
            right.add(s[x])
    ans=max(ans,len(left & right))
print(ans)

Solution (Python):
n = int(input())
s = input()
ans = 0
for i in range(1,n - 1):
    cnt = 0
    for j in range(0,26):
        a = b = False
        for k in range(0,n):
            if ord(s[k]) == j + ord('a'):
                if k < i:
                    a = True
                else:
                    b = True
        if a and b:
            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()

def match_num(A, B):
    m=[]
    for a in A:
        if a in B and a not in m:
            m.append(a)
    return m

match_nums=[]
for n in range(1, N):
    
    
    if n <= N//2:
        
        
        match_nums.append(len(match_num(S[:n], S[n:])))
        
    else:
        
        
        match_nums.append(len(match_num(S[n:], S[:n])))
print(max(match_nums))

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 = input()

ans = 0
for i in range(1, len(S)):
  L = set(S[:i])
  R = S[i:]

  cnt = 0
  for j in L:
    if j in R:
      cnt += 1
  ans = max(ans, cnt)
print(ans)

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())
dic={}
count=0
for i in S:
    if not i in dic.keys():
        dic[i]=[count]
    else:
        dic[i].append(count)
    count+=1

max_count=0
for j in range(1,N+1):
    count=0
    for key,value in dic.items():
        if len(value)==1:
            continue
        else:
            if value[0]<=j and j<value[-1]:
                count+=1
    if max_count<count:
        max_count=count
print(max_count)

Solution (Python):
import sys

input = sys.stdin.readline


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


if __name__ == "__main__":
    main()

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

m = 0
for i in range(N):
    index = len(set(S[0:i]) & set(S[i:N]))
    if m < index: m = index

print(m)

Solution (Python):
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    
cnt=0
n=int(input())
s=input()

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

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

max_cnt = 0
for i in range(2, N):
    first_half = set(S[0:i])
    latter_half = set(S[i:N+1])

    intersect = first_half & latter_half

    max_cnt = max(max_cnt, len(intersect))

print(max_cnt)

Solution (Python):
N = int(input())
x = input()
m = 0
sumy = 0
for i in range(N):
    sumx = 0
    a = []
    b = []
    c = []
    for j in range(N):
                
        if j<i:
            a.append(x[j])
        else:
            b.append(x[j])
    for k in range(len(b)):
        if any([l==b[k] for l in a]) and not any(b[k]==n for n in c):
            sumx+=1
            c.append(b[k])
    if sumy<sumx:
        sumy = sumx

print(sumy)

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

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

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

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

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

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

L = []
for i in range(N):
    L.append(S[i])
    
ans = 0
for i in range(1, N+1):
    c = 0
    temp1 = L[0:i]
    temp2 = L[i:N+1]
    temp1_set = set(temp1)
    temp2_set = set(temp2)
    temp1 = list(temp1_set)
    temp2 = list(temp2_set)
    for j in range(len(temp1)):
        for k in range(len(temp2)):
            if temp1[j] == temp2[k]:
                c += 1
                break
    if ans < c:
        ans = c
        
print(ans)

Solution (Python):

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


alphabets_list = [c for c in "abcdefghijklmnopqrstuvwxyz"]


result = []
for i in range(1, n):
    x = s[ :i]
    y = s[i: ]
    count = 0
    for alphabet in alphabets_list:
        if (alphabet in x) and (alphabet in y):
            count += 1
        else:
            count += 0
    result.append(count)

print(max(result))

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

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

Solution (Python):
N = int(input())
S = input()
a = set(S[:1])
b = set(S[1:])
M = len(a & b)

for i in range(2,N):
  a = set(S[:i])
  b = set(S[i:])
  if len(a & b) > M:
    M = len(a & b)

print(M)

Solution (Python):
n = int(input())
s = list(input())
import copy
M = 0
for i in range(n):
    count = 0
    l1 = copy.copy(s[0 : i + 1])
    l2 = copy.copy(s[i + 1 : n])
    l1 = list(set(l1))
    l2 = list(set(l2))
    for j in range(len(l1)):
        if l1[j] in l2:
            count += 1
    if count > M:
        M = count
print(int(M))

Solution (Python):
n = int(input())
s = list(input())
l = []
for i in range(len(s)):
    x = set(s[:i])
    y = set(s[i:])
    li = list((x & y))
    for i in li:
        if li.count(i) >= 2:
            while True:
                if li.count(i) == 1:
                    break
                else :
                    li.remove(i)
    l.append(len(li))
print(max(l))

Solution (Python):
n = int(input())
S = input()
letters = list("abcdefghijklmnopqrstuvwxyz")
print(max([len([x for x in letters if (x in S[:i]) & (x in S[i:])]) for i in range(1, n)]))

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 = input()
count = 0
for i in range(n):
    if len(set(s[:i])&set(s[i:])) > count:count = len(set(s[:i])&set(s[i:]))
print(count)

Solution (Python):
N = int(input())
S = input()
S_set = set(S)
dict_right = {}
dict_left = {}
num_list = [0]

for st in S_set:
    dict_right[st] = S.count(st)
    dict_left[st] = 0
for s in S:
    if dict_left[s] == 0 and dict_right[s] != 1:
        num_list.append(num_list[-1] + 1)
    elif dict_left[s] != 0 and dict_right[s] == 1:
        num_list.append(num_list[-1] - 1)
    dict_right[s] -= 1
    dict_left[s] += 1
print(max(num_list))

Solution (Python):
import copy
n=input()
n=int(n)
s=input()
l=[]
indexs=[]
for i in range(n):
  l.append(s[i])
lr=copy.deepcopy(l)
lr.reverse()
se=set(l)
for k in se:
  if l.index(k)+lr.index(k)!=n-1:
    indexs.append([l.index(k),n-1-lr.index(k)])
count=[0]*n
for j in range(len(indexs)):
  for t in range(indexs[j][0],indexs[j][1]):
    count[t]+=1
print(max(count))

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
  if ans < len(c):
    ans = len(c)
print(ans)

Solution (Python):


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

ans = 0

for i in range(N):
  
  
  X = list(set(S[0 : i + 1]))
  Y = list(set(S[i + 1 : N]))
  
  temp = 0
  
  for x in X:
    for y in Y:
      if x == y:
        temp += 1
        break
  
  if temp > ans:
    ans = temp

print(ans)

Solution (Python):
from collections import Counter

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

ans = 0
for i in range(N-1):
  X = S[:i+1]
  Y = S[i+1:]
  temp = 0
  for s in Counter(X).keys():
    if s in Y:
      temp += 1
  ans = max(ans, temp)
print(ans)

Solution (Python):


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

ans = 0

for i in range(N):
  
  X = list(set(S[0 : i + 1]))
  Y = list(set(S[i + 1 : N]))
  
  temp = 0
  
  for x in X:
    for y in Y:
      if x == y:
        temp += 1
        break
  
  if temp > ans:
    ans = temp

print(ans)

Solution (Python):
n = int(input())
s = input()
cnt_max = 0
for i in range(1,n):
  s_1 = set(s[:i])
  s_2 = set(s[i:])
  cnt = 0
  for p in s_1:
    if p in s_2:
      cnt += 1
  cnt_max = max(cnt ,cnt_max)
print(cnt_max)

Solution (Python):
n = int(input())
s = input()
ans = 0
for i in range(1,n):
  k = 0
  for j in range(97,123):
    if s[:i].count(chr(j))*s[i:].count(chr(j)):
      k += 1
  ans = max(k,ans)
print(ans)

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

ans = 0
for i in range(1,len(s)):
    x = set(s[:i])
    y = s[i:]
    tmp = 0
    for j in x:
        if j in y:
            tmp += 1
    if ans < tmp:
        ans = tmp
print(ans)

Solution (Python):
def count(strings):
    s = set()
    for c in strings:
        s.add(c)
    return s


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

Solution (Python):
N = int(input())
S = list(input())
ans1 = 0
for i in range(1,N):
  ans = 0
  a = S[:i]
  b = S[i:]
  a.sort()
  c = a[0]
  if c in b:
    ans +=1
  for j in range(1,len(a)):
    if a[j]!=c and a[j] in b:
      ans +=1
      c = a[j]
  ans1 = max(ans,ans1)
print(ans1)

Solution (Python):
n = int(input())
s = list(input())
max_count = 0
for i in range(1,n):
    count = 0
    l = set(s[0:i])
    r = set(s[i:n])
    for j in r:
        if j in l:
            count = count + 1
    else:
        if count > max_count:
            max_count = count

print(max_count)

Solution (Python):
def bb098():
    n = int(input())
    s = input()
    t = list(s)

    u = list(set(t)) 
    if len(u) == 1:
        print(1)
        import sys
        sys.exit()

    mx = 0
    for i in range(1, n-1):
        v = t[0:i]
        w = t[i:]
        vw = list(set(v) & set(w))
        if len(vw) > mx:
            mx = len(vw)

    print(mx)

bb098()

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=[i for i in input()]
a=[]
for i in range(1,n):
    k=0
    x=list(set(s[:i]))
    y=list(set(s[i:]))
    for j in range(len(x)):
        if x[j] in y:
            k+=1
    a.append(k)
print(max(a))

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

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

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

ture_count_list = []
for i in range(1, N):
    count_list = []
    left_S_list = []
    for s in S[0:i]:
        if s not in left_S_list:
            left_S_list.append(s)
        else:
            pass
    for m in left_S_list:
        if m in S[i:]:
            count_list.append(True)
        else:
            count_list.append(False)
        ture_count_list.append(count_list.count(True))


print(max(ture_count_list))