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

slist=list(s)
maxlist=[]
for i in range(1,n):
    maximum=0
    sr=slist[:i]
    sl=slist[i:]
    if sr.count("a")!=0 and sl.count("a")!=0:
        maximum+=1
    if sr.count("b")!=0 and sl.count("b")!=0:
        maximum+=1
    if sr.count("c")!=0 and sl.count("c")!=0:
        maximum+=1
    if sr.count("d")!=0 and sl.count("d")!=0:
        maximum+=1
    if sr.count("e")!=0 and sl.count("e")!=0:
        maximum+=1
    if sr.count("f")!=0 and sl.count("f")!=0:
        maximum+=1
    if sr.count("g")!=0 and sl.count("g")!=0:
        maximum+=1
    if sr.count("h")!=0 and sl.count("h")!=0:
        maximum+=1
    if sr.count("i")!=0 and sl.count("i")!=0:
        maximum+=1
    if sr.count("j")!=0 and sl.count("j")!=0:
        maximum+=1
    if sr.count("k")!=0 and sl.count("k")!=0:
        maximum+=1
    if sr.count("l")!=0 and sl.count("l")!=0:
        maximum+=1
    if sr.count("m")!=0 and sl.count("m")!=0:
        maximum+=1
    if sr.count("n")!=0 and sl.count("n")!=0:
        maximum+=1
    if sr.count("o")!=0 and sl.count("o")!=0:
        maximum+=1
    if sr.count("p")!=0 and sl.count("p")!=0:
        maximum+=1
    if sr.count("q")!=0 and sl.count("q")!=0:
        maximum+=1
    if sr.count("r")!=0 and sl.count("r")!=0:
        maximum+=1
    if sr.count("s")!=0 and sl.count("s")!=0:
        maximum+=1
    if sr.count("t")!=0 and sl.count("t")!=0:
        maximum+=1
    if sr.count("u")!=0 and sl.count("u")!=0:
        maximum+=1
    if sr.count("v")!=0 and sl.count("v")!=0:
        maximum+=1
    if sr.count("w")!=0 and sl.count("w")!=0:
        maximum+=1
    if sr.count("x")!=0 and sl.count("x")!=0:
        maximum+=1
    if sr.count("y")!=0 and sl.count("y")!=0:
        maximum+=1
    if sr.count("z")!=0 and sl.count("z")!=0:
        maximum+=1
    maxlist.append(maximum)

print(max(maxlist))

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):
import sys
n = int(input())
s = input()
count_max = 0
for i in range(1,n):
    if len(set(s[:i]) & set(s[i:])) >count_max:
        count_max = len(set(s[:i]) & set(s[i:]))
print(count_max)

Solution (Python):
def main():
  N = int(input())
  S = input()
  M = 0

  for i in range(1, N):
    s1 = set(list(S[:i]))
    s2 = set(list(S[i:]))

    M = max(M, len(s1.intersection(s2)))

  print(M)


if __name__ == "__main__":
  main()

Solution (Python):
n=int(input())
s=input()
s_list=[]
for i in range(len(s)):
    s_list.append(s[i])

ans_list=[]
for j in range(len(s_list)):
    ans=len(set(s_list[:j])&set(s_list[j:]))
    ans_list.append(ans)

ans_list.sort()
print(ans_list[-1])

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

K = []
for i in range(1,N):
    X = set(S[:i])
    Y = set(S[i:])
    K.append(len(X & Y))

print(max(K))

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

K = []
for i in range(1,N):
    X = list(set(S[:i]))
    Y = list(set(S[i:]))
    cnt = 0
    for i in range(len(X)):
        if X[i] in Y:
            cnt += 1

    K.append(cnt)

print(max(K))

Solution (Python):

def read_input():
    n = int(input())
    s = input()

    return n, s

def submit():
    n, s = read_input()

    max_common = 0
    for i in range(1, n):
        f = s[:i]
        l = s[i:]

        fc = set([c for c in f])
        lc = set([c for c in l])

        common = fc.intersection(lc)
        if max_common < len(common):
            max_common = len(common)

    print(max_common)

if __name__ == '__main__':
    submit()

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

Solution (Python):
N=int(input())
S=input()
F=[]
B=[]
max=0

for i in range(1,N):
	F=S[0:i]
	B=S[i:N]
	tmp=set(F)&set(B)
	if tmp=='set()': tmp=0
	else: tmp=len(list(tmp))
	if max<tmp:
		max=tmp
print(max)

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

Solution (Python):
n = int(input())
s = input()
res = 0
for i in range(1,n):
    b,c =(s[:i], s[i:])
    cnt = 0
    for j in range(26):
        p = chr(ord('a') + j)
        cnt += (p in b) and (p in c)
    res = max(res, cnt)
print(res)

Solution (Python):
N = int(input())
S = input()
ans = [0]
for i in range(N):
    L = set(S[:i])
    R = set(S[i:])
    ans.append(len(list(L.intersection(R))))
print(max(ans))

Solution (Python):

import numpy as np
import math
import re

n = int(input())

x = input()
max = 0
for i in range(n):
    s = 0
    list1 = set(x[0:i])
    list2 = set(x[i:n])
    for j in list1:
        if j in list2:
            s += 1
    if s > max:
        max = s
print(max)

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

z = []
for i in range(1,N):
  x = S[:i]
  y = S[i:]
  if set(x) & set(y):
    z.append(len(set(x)&set(y)))
  else:
    continue

print(max(z) if len(z) != 0 else 0)

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

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

print(z)

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

Solution (Python):
from collections import Counter
n = int(input())
s = list(input())
ans = 0
for i in range(n):
    c1 = Counter(s[:i])
    c2 = Counter(s[i:])
    count = 0
    for k in c1.keys():
        if k in c2.keys():
            count += 1
    ans = max(ans, count)
print(ans)

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

Solution (Python):
a = input()
n = list(input())
maxnum = -1
for i in range(len(n)):
    x = set(n[:i])
    y = set(n[i:])
    maxnum = max(maxnum, len(x & y))

print(maxnum)

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

for i in range(N):
    A=S[:i]
    B=S[i:]
    sum=0
    l=set()
    for j in A:
        if (j in B) and (j not in l):
            sum+=1
            l.add(j)
    ans=max(sum,ans)
print(ans)

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 = list(input())
alfabets = [chr(i) for i in range(97,97+26)]
numbers = []
for i in range(0,n-1) :
    cnt = 0
    a = s[0:i+1]
    b = s[i+1:n]
    for j in alfabets :
        if j in a and j in b :
            cnt += 1
    numbers.append(cnt)

print(max(numbers))

Solution (Python):
import sys

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

for i in range(1, len(s)):
    x_set = set(s[0:i])
    y_set = set(s[i::])
    xy_insect = x_set & y_set
    if len(xy_insect) and ans < len(xy_insect):
        ans = len(xy_insect)

print(ans)

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()
sets = len(set(s))
ans = 0
for i in range(1,len(s)):
    x = set(s[:i])
    y = set(s[i:])
    ans = max(ans, len(x & y))
print(ans)

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

Solution (Python):

import sys


def solve(N: int, S: str):
    ret = 0
    for i in range(N):
        ret = max(ret, len(set(S[:i]).intersection(set(S[i:]))))
    print(ret)



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):
import sys
input = sys.stdin.readline

n = int(input())
s = list(input())
cnt = 0
ans = 0
for i in range(1,n):
    a = s[:i]
    b = s[i:]

    a = list(set(a))
    b = list(set(b))

    a.sort()
    b.sort()

    for j in range(len(a)):
        if a[j] in b:
            cnt += 1
    
    if ans<cnt:
        ans = cnt

    cnt = 0

print(ans)

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

box = []
s = set()
for i in range(N):
    for j in range(0, i):
        if S[j] in S[i:]:
            s.add(S[j])
    box.append(len(s))
    s = set()
    
print(max(box))

Solution (Python):

import collections

n = int(input())
s = input().rstrip()
count = 0
answer = 0
lst = [i for i in s]

if collections.Counter(lst) == 1:
    print(1)
else:
    for i in range(1, n):
        count = 0
        lst_sub1 = lst[:i]
        lst_sub2 = lst[i:]

        set_sub1 = set(lst_sub1)
        set_sub2 = set(lst_sub2)

        for j in set_sub1:
            if j in set_sub2:
                count += 1
        answer = max(answer, count)

    print(answer)

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

print(ans)

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

Solution (Python):
def main():
	N = int(input())
	S = input()
	ans = 0
	for i in range(1, N-1):
		this_ans = 0
		appear = set()
		for j in range(i):
			appear.add(S[j])
		
		already = set()
		for j in range(i, N):
			if S[j] in appear and not S[j] in already:
				this_ans += 1
				already.add(S[j])
		ans = max(ans, this_ans)

	print(ans)


if __name__ == '__main__':
	main()

Solution (Python):
N = int(input())
S = input()
m = 0
for i in range(N-1):
  a = S[:i+1]
  b = S[i+1:]
  c = 0
  for j in list(set(a)):
    if j in b:
      c += 1
  if c > m:
    m = c
print(m)

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


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

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

vmax = 0
for n in range(1, N - 1):
	vmax = max(vmax, len(set(S[:n]) & set(S[n:])))
print(vmax)

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

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

ans = 0

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

print(ans)

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

for i in range(N):
    S1=S[:i]
    S2=S[i:]
    se=set()
    t=0
    for j in S2:
        if j in S1 and not(j in se):
            se.add(j)
            t+=1
    res=max(res,t)
print(res)

Solution (Python):

import sys
INF = float("inf")


def solve(N: int, S: str):

    m = -INF
    for i in range(1, N):          
        kind = 0
        for c in set(S[:i]):
            if S[i:].count(c) > 0:
                kind += 1
        if kind > m:
            m = kind
        
    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 = list(input())
ans = 0

for i in range(N):
    T = S[:i]
    U = S[i:]
    commonTU = set(T) & set(U)
    cnt = len(commonTU)
    ans = max(cnt,ans)
print(ans)

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

ans = 0

for i in range(len(s) - 2):
    s1 = list(set(s[:i + 1]))
    s2 = list(set(s[i + 1:]))

    j = 0
    for x in s1:
        if x in s2:
            j += 1
    ans = max(ans, j)

print(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()

answer = 0

for i in range(N):
    x = set(S[:i])
    y = set(S[i:])
    a = len(x&y)
    answer = max(a, answer)

print(answer)

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

Solution (Python):
from collections import Counter
def MI(): return map(int, input().split())
def II(): return int(input())
def IS(): return input()
def LI(): return list(map(int, input().split()))


n = II()
s = IS()
ans = 0
cuts = [[s[:i],s[i:]] for i in range(1,len(s))]
for cut in cuts:
    count = 0 
    for char in set(cut[0]):
        if char in set(cut[1]):
            count += 1
            ans = max(ans, count)
print(ans)

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

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

print(ans)

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

max = 0
for i in range(N-1):
    s1 = S[:i+1]
    s2 = S[i+1:]
    s1 = list(set(s1))
    s2 = list(set(s2))
    count = 0
    for e in s1:
        if e in s2:
            count += 1
    if count > max:
        max = count

print(max)

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

for i in range(1,n-1):
    a = set(s[:i])
    b = set(s[i:])
    cnt = len(a) + len(b) - len(set(s))
    c = max(c,cnt)

print(c)

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

for i in range(1,n-1):
    a = set(s[:i])
    b = set(s[i:])
    cnt = len(a) + len(b) - len(a|b)
    c = max(c,cnt)

print(c)

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

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

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

Solution (Python):
N = int(input())
S = input()
import string
abcs = string.ascii_lowercase

ans = 0
for sakaime in range(N):
    cnt = 0
    left = S[:sakaime]
    right = S[sakaime:]
    for alpha in abcs:
        if alpha in left and alpha in right:
            cnt += 1
    ans = max(ans, cnt)
    
print(ans)

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

ans = 0
for sakaime in range(N):
    left = set(S[:sakaime])
    right = set(S[sakaime:])
 
    cnt = len(left.intersection(right))
    ans = max(ans, cnt)

print(ans)

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

def f(s,t):
    a=set(s)
    b=set(t)
    c=a&b
    return len(c)

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

Solution (Python):
n=int(input())
s=str(input())
s1=''
s2=''
max=0
for i in range(1,n-1):
  count={}
  s1=s[:i]
  s2=s[i:]
  for j in range(len(s1)):
    if s2.count(s1[j]) >= 1:
      count[s1[j]]=1
  data=list(count.keys())
  if len(data) > max:
    max=len(data)
print(max)

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

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

def countCommonLetter(X, Y):
    return len(set([x for x in X if x in Y]))

def solve():
    return max ( [countCommonLetter( s[:i], s[i:] ) for i in range(1, N)] )

print( solve() )

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

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

Solution (Python):
N = int(input())
S = input()
max_cnt = 0
for i in range(N):
  li1 = [0]*26
  li2 = [0]*26
  cnt = 0
  for j in S[i:]:
    li1[ord(j)-97]+=1
  for j in S[:i]:
    li2[ord(j)-97]+=1
  for j in range(26):
    if(li1[j]>0 and li2[j]>0):
      cnt += 1
  max_cnt = max(max_cnt,cnt)
print(max_cnt)

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 = str(input())
max = 0
list_S = list(S)
for i in range(N-1):
    X = list_S[:i]
    Y = list_S[-(len(list_S)-i):]
    result = set(X) & set(Y)
    if max < len(result):
        max = len(result)
print(max)

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

ans = -1
for i in range(N):
    x = len(set(list(S[:i]))&set(list(S[i:])))
    if x > ans:
        ans = x

print(ans)

Solution (Python):
n=int(input())
ori=input()
max=0
for i in range(n-1):
    former=ori[:i+1]
    latter=ori[i+1:n]
    common=0
    for j in range(26):
        if chr(j+97) in former and chr(j+97) in latter:
            common+=1
        if max<=common:
            max=common
    
print(max)

Solution (Python):
N = int(input())
s = input()
ans = 0
for i in range(1, N-1):
    cnt = 0
    X = s[:i]
    Y = s[i:]
    alpX = [0 for j in range(26)]
    alpY = [0 for j in range(26)]
    lenX = i
    lenY = N-i
    for j in range(lenX):
        alpX[ord(X[j])-97] += 1
    for j in range(lenY):
        alpY[ord(Y[j])-97] += 1
    for j in range(26):
        if alpX[j] != 0 and alpY[j] != 0:
            cnt += 1 
    if ans < cnt:
        ans = cnt
print(str(ans))

Solution (Python):
_,a=open(0);print(max(len(set(a[:s])&set(a[s:]))for s in range(99)))

Solution (Python):
n = int(input())
s = input()
ans = 0
for i in range(1,n-1):
    s1 = s[:i]
    s2 = s[i:]
    cnt =0 
    for x in 'abcdefghijklmnopqrstuvwxyz':
        if x in s1 and x in s2:
            cnt += 1
    ans = max(ans, cnt)
print(ans)

Solution (Python):
n = int(raw_input())
s = str(raw_input())
count = 0
for i in range(1,n):
	x = list(s[:i])
	y = list(s[i:])
	com = set(x) & set(y)
	count = max(count, len(com))
print count

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

Solution (Python):
n=int(input())
oristr=input()
max=0
for i in range(n-1):
  former=oristr[0:i+1]
  latter=oristr[i+1:n]
  common=0
  for j in range(26):
    if chr(j+97) in former and chr(j+97) in latter:
      common+=1
  if max<=common:
    max=common
print(max)

Solution (Python):
N = input()
S = input().strip()

res = []

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

print(max(res))

Solution (Python):
n,s=int(input()),input()
maxcount=0
for i in range(1,n+1):
  count=0
  x,y=s[:i],s[i:]
  for t in set(s):
    if t in x and t in y:
      count+=1
  if maxcount<count:
    maxcount=count
print(maxcount)

Solution (Python):


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

def list_intersection(a,b):
    c = []
    for i in range(len(a)):
        for j in range(len(b)):
            if a[i] == b[j]:
                c.append(a[i])
                a[i] = "_"
                b[j] = "&"
    return c

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

print(ans)

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

m = 0

for i in range(1, N):
    ans = 0
    X = S[:i]
    Xu = list(set(X))
    Y = S[i:]
    for a in Xu:
        if(Y.count(a)>0):
            ans+=1
    m = max(m, ans)

print(m)

Solution (Python):
al = [chr(i) for i in range(97,97 + 26)]

def cnt(s,t):
	ret = 0
	for c in al:
		if c in s and c in t:ret+=1
	return ret

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

Solution (Python):
import collections as col
N = int(input())
S = input()
SMae, SAto = '', ''
SCol = col.Counter(S).most_common()
Ans = [0]*(N-1)

for i in range(N-1):
    SMae, SAto = S[:i+1], S[i+1:]
    for j in SCol:
        if j[0] in SMae and j[0] in SAto:
            Ans[i] += 1

print(max(Ans))

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):
from sys import stdin
N=int(stdin.readline().rstrip())
S=(stdin.readline().rstrip())
ans=0
for i in range(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()
ans = []
for i in range(1, N):
    X = S[: i + 1]
    Y = S[i + 1 :]
    setlist = list(set(X)) + list(set(Y))
    ans.append(len(setlist) - len(set(setlist)))
print(max(ans))

Solution (Python):

from collections import Counter
N = int(input())
S = input()
ans = 0
for i in range(1, N):
    cnt = 0
    left, right = S[:i], S[i:]
    longer, shorter = max(left, right), min(left, right)
    for j in range(len(longer)):
        if longer[j] in shorter and longer[j] not in longer[:j]:
            cnt += 1
    ans = max(ans, cnt)
print(ans)

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

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

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

Solution (Python):
N = int(input())
S = list(input())
max_ntypes = 0
for i in range(N):
    left = set(S[0:i+1])
    right = set(S[i+1:N])
    n = len(list(left & right))
    if n > max_ntypes:
        max_ntypes = n
print(max_ntypes)

Solution (Python):
n = int(input())
s = input()
count_list = []
for i in range(1,n):
    count = 0
    left_list = set(s[:i])
    right_list = set(s[i:])
    for moji in left_list:
        if moji in right_list:
            count += 1
    count_list.append(count)
print(max(count_list))

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

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

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

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

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

ans = 0
for i in range(n):
    d = {}
    for j in s[:i]:
        if d.get(j, 0) == 0:
            d[j] = 1
    for j in s[i:]:
        if d.get(j, 0) == 1:
            d[j] = 2
    t = 0
    for j in d:
        if d[j] == 2:
            t += 1
    ans = max(ans, t)

print (ans)

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

Solution (Python):
import collections
N = int(input())
S = list(input())
m = 0
for i in range(1, N):
    A = S[:i]
    B = S[i:]
    m = max(m, len(collections.Counter(A))+len(collections.Counter(B)))
print(m - len(collections.Counter(S)))

Solution (Python):
def skind(x,y):
  ans,s=0,[]
  for i in range(len(x)):
    if x[i] in y and not x[i] in s:
      ans+=1
      s.append(x[i])
  return ans
n,s,ans=int(input()),input(),0
for i in range(n-1):ans=max(ans,skind(s[:i+1],s[i+1:]))
print(ans)

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

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

print(ans)

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

ans = 0
for i in range(n):
  count = 0
  checked = []
  for item in s[:i]:
    if item not in checked:
      if item in s[i:]:
        count += 1
      checked.append(item)
  ans = max(ans, count)
  
print(ans)

Solution (Python):
from sys import stdin
n = int(stdin.readline().rstrip())
s = stdin.readline().rstrip()
types=[]
for i in range(1,len(s)+1):
    types.append(len(set(s[:i]) & set(s[i:])))
print(max(types))

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

answer =0
for i in range(1,N-1):
  X = S[:i]
  Y = S[i:]
  count=0
  for l in 'abcdefghijklmnopqrstuvwxyz':
    if l in X and l in Y:
      count +=1
  answer =max(answer, count)
  
print(answer)

Solution (Python):
N=int(input())
S=input()
F=[]
L=[]
max=0
for i in range(0,N+1):
    F=set(S[:i])
    L=set(S[i:])
    count=len(F&L)
    if count>max:
        max=count
    F=[]
    L=[]
print(max)

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

Solution (Python):

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



def word_count(word):
    member = []
    for w in word:
        if not(w in member):
            member.append(w)
    return member

max_word = 0
for i in range(1,n):
    cut_place = i 
    x = s[:i]
    y = s[i:]
    curr_word = 0
    x_s = word_count(x)
    y_s = word_count(y)
    for j in x_s:
        if j in y_s:
            curr_word += 1
    if max_word < curr_word:
        max_word = curr_word

print(max_word)

Solution (Python):
N=int(input())
S=input()
result=[]
for i in range(1,N):
  result.append(sum([1 for s in set(list(S[:i])) if s in S[i:]]))
print(max(result))

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

ans = 0
for i in range(1, n-1):
    x = len(set(sli[:i]) & set(sli[i:]))
    if ans < x:
        ans = x

print(ans)

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

kind = []

for i in range(N - 1):
    left = set(S[:i + 1])
    right = set(S[i + 1:])
    kind.append(len(left & right))

print(max(kind))

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

for i in range(1, N):
    X = S[:i]
    Y = S[i:]
    tmp = len(set(X) & set(Y))
    if tmp > ResMax:
        ResMax = tmp

print(ResMax)

Solution (Python):
N=int(input())
S=input()
m=[]
for i in range(N):
    m.append(len(set(S[:i])&set(S[i:])))
print(max(m))

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

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

ans = 0

for i in range(1, n):
    a, b = set(s[:i]), set(s[i:])
    if ans < len(a & b):
        ans = len(a & b)
print(ans)

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

max_chars = 0
for i in range(1, N):
    left = S[:i]
    right = S[i:]

    s1 = set()
    s2 = set()
    for l in left:
        s1.add(l)
    for r in right:
        s2.add(r)
    s3 = s1 & s2
    count = len(s3)
    if max_chars < count:
        max_chars = count
print(max_chars)

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

vmax = 0
for i in range(n):
    s0 = s[:i]
    s1 = s[i:]

    v = len(set(set(s0) & set(s1)))
    vmax = max(vmax, v)

print(vmax)

Solution (Python):
import collections
n=int(input())
s=list(str(input()))
l=[]

c=collections.Counter(s)


for i in range(1,n):
    x=s[:i]
    y=s[i:]
    xc=collections.Counter(x)
    yc=collections.Counter(y)
    l.append(len(xc.values())+len(yc.values())-len(c.values()))
    
print(max(l))

Solution (Python):
n = int(input())
s = input()
ss = list(set(s))
answer = 0


for i in range(n):
	kari = 0
	x = s[:i]
	y = s[i:]
	for j in ss:
		if j in x:
			if j in y:
				kari += 1
	answer = max(answer, kari)
	
print(answer)

Solution (Python):
N = int(input())
S = input()
ans = 0
for i in range(1, N):
    X = S[:i]
    Y = S[i:]
    count = 0
    for j in range(26):
        if chr(ord("a") + j) in X and chr(ord("a") + j) in Y:
            count += 1
    if count > ans:
        ans = count
print(ans)

Solution (Python):
n = int(input())
s = input()
maxcnt = 0
for i in range(n-1):
    cnt = 0
    for p in set(s[:i+1]):
        if p in s[i+1:]:
            cnt += 1
    if cnt > maxcnt:
        maxcnt = cnt
print(maxcnt)

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

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

print(ans)

Solution (Python):
def solve(string):
    n, s = string.split()
    return str(max([len(set(s[:i]) & set(s[i:])) for i in range(1, int(n))]))


if __name__ == '__main__':
    print(solve("\n".join([input(), input()])))

Solution (Python):
N = int(input())
S = input()
ret = 0
for x in range(1, N):
    s1 = set(S[0:x])
    s2 = set(S[x:])
    ret = max(ret, len(s1 & s2))
print(ret)

Solution (Python):
n = int(input())
b = input()
 
largest = -1
for i in range(n):
  l = len(set(b[:i]) & set(b[i:]))
  largest = l if largest < l else largest
 
print(largest)

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

Solution (Python):
n = int(input())
s = input()
maximum = 0
for i in range(n):
    kind = len(set(s[0:i]) & set(s[i:]))
    if kind > maximum :
        maximum = kind
print(maximum)

Solution (Python):
n = int(input())
s = input()
maximum = 0
for i in range(n):
    x = s[0:i]
    y = s[i:]
    kind = len(set(x) & set(y))
    if kind > maximum :
        maximum = kind

print(maximum)

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

max_score = 0
for i in range(1,n-1):
    s1 = s[:i]
    s2 = s[i:]
    dic = []

    for x in s1:
        if x in s2 and x not in dic:
            dic.append(x)

    if max_score < len(dic):
        max_score = len(dic)

print(max_score)

Solution (Python):




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

ans = 0
for i in range(1,N):
  dct = {}
  for c in S[:i]:
    if c in S[i:]:
      if c not in dct:
        dct[c] = 1
      else:
        dct[c] += 1
  ans = max(ans, len(dct))
print(ans)

Solution (Python):
N = int(input())
S = str(input())
ans_li = []
for i in range(1,N,1):
  tmp_1 = list(set(S[i:]))
  tmp_2 = list(set(S[:i]))
  tmp_3 = set(tmp_1)&set(tmp_2)
  ans_li.append(len(tmp_3))
print(max(ans_li))

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):

import sys

def main():
	N = int(input())
	tmp = input()
	S = list(tmp)
	
	ans_max = 0
	for i, val in enumerate(S):
		ans = 0
		S1 = []
		S2 = []
		if i == N-1:
			continue
			
		for j, vol in enumerate(S):
			if i < j:
				S2.append(vol)
			else:
				S1.append(vol)
			
		strings = []
		for i in S1:
			for j in S2:
				if i == j:
					strings.append(i)
		l_unique = list(set(strings))
		ans = len(l_unique)
		if ans_max < ans:
			ans_max = ans
				
	print(ans_max)
		
if __name__ == "__main__":
	main()