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();print(max(len(set(s[:i])&set(s[i:]))for i in range(n)))

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

for i in range(N):
    a = set(S[:i])
    b = set(S[i:])
    c = (a & b)
    if num < len(c):
        num = len(c)
print(num)

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

for i in range(N):
    count = 0
    alp = []
    for s in S[:i+1]:
        if s in S[i+1:] and s not in alp:
            count += 1
            alp.append(s)
    if maxcount < count:
        maxcount = count
print(maxcount)

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()
c=0
for i in range(1,n):
    p=set(s[:i])
    b=set(s[i:])
    c=max(c,len(p&b))
print(c)

Solution (Python):
import sys

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


kind = len(st)
maxi = 0

for i in range(1,len(S)-1):
    
    l = set(S[:i])
    r = set(S[i:])
    tmp = len(l&r)
    
    maxi = max(tmp,maxi)

print(maxi)

Solution (Python):
n=int(input())
s=input()
d=0
for i in range(1,n):
  S=[]
  for t in s[:i:]:
    if t in s[i::]:
      S.append(t)
  S=list(set(S))
  d=max(d,len(S))
print(d)

Solution (Python):
input()
s=input()
cnt=0
for i in range(len(s)):
    x=set(s[:i])
    y=set(s[i:])
    if cnt<len(x&y):
        cnt=len(x&y)
print(cnt)

Solution (Python):
input()
s = input()
ans = 0
for i in range(len(s)):
    a = set(s[:i])
    b = set(s[i:])
    if len(a & b) > ans: ans = len(a&b)
print(ans)

Solution (Python):
a = int(input())
s = input()
A = []
count=0
for i in range(1, a):
    x = list(s[:i])
    y = list(s[i:])

    x = list(set(x))
    y = list(set(y))

    for i in y:
        if(i in x):
            count+=1
    A.append(count)
    count=0
print(max(A))

Solution (Python):

import sys
input = sys.stdin.readline

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

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

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

print(ans)

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



separater=1
while separater<N:
    former_list = []
    latter_list = []
    former_set = {}
    latter_set = {}
    former_string=S[:separater]
    latter_string=S[separater:N]
    former_set=set(list(former_string))
    latter_set=set(list(latter_string))
    intersection=former_set & latter_set
    if now_max<len(intersection):
        now_max=len(intersection)

    
    
    

    separater+=1
print(now_max)

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

Solution (Python):
N = int(input())
S = input()
count = []
for i in range(1, N):
    z = []
    x = list(set(S[:i]))
    y = list(set(S[i:]))
    for j in x:
        z += filter(lambda str: str == j, y)
    count.append(len(z))
print(max(count))

Solution (Python):
n = int(input())
s = input()
ls = [s[k:k+1] for k in range(n)]


res = 0
for i in range(1,n):
  f = list(set(ls[0:i]))
  b = list(set(ls[i:n]))
  
  tmp = 0
  for j in range(len(f)):
    if b.count(f[j]) > 0:
      tmp += 1
  if tmp > res:
    res = tmp

print(res)

Solution (Python):
N = int(input())
l = [i for i in input()]
ans = 0

for i in range(len(l)):
  a = len(set(l[:i]))
  b = len(set(l[i:]))
  ans = max(ans,a+b-len(set(l)))

print(ans)

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

print(ans)

Solution (Python):



def main():
    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)


if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
S = input()
T = list(set(S))
i = 1
ans = 0
while i < N:
  S1 = S[0:i]
  S2 = S[i:N]
  con = 0
  for j in range (len(T)):
     if S1.find(T[j]) > -1 and S2.find(T[j]) > -1:
        con += 1
  if con > ans:
    ans = con
  i += 1
print(ans)

Solution (Python):



def main():
    """Function."""
    n = int(input())
    s = str(input())

    max_val = 0
    for i in range(n-1):
        left, right = s[:i+1], s[i+1:]

        l_check, r_check = set(list(left)), set(list(right))
        temp = len(l_check & r_check)
        if temp > max_val:
            max_val = temp

    print(max_val)


if __name__ == "__main__":
    main()

Solution (Python):
n=int(input())
s=input()
ans=0
for i in range(n-2):
  kr=0
  for j in [chr(k) for k in range(97,97+26)]:
    if s[0:i+1].count(j)>=1 and s[i+1:n].count(j)>=1:
      kr+=1
  if ans<kr:
    ans=kr
print(ans)

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

output=0

for i in range(N-1):
    X=S[:i]
    Y=S[i:]
    
    cap=len(set(list(X))&set(list(Y)))
    output=max(output,cap)
print(output)

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

m = 0
for i in range(1, N):
  m = max(m, len(set(S[:i]).intersection(S[i:])))

print(m)

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

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

MAX = 0
for i in range(n-1):
    x = s[:i+1]
    y = s[i+1:]
    tmp = len(set(list(x)).intersection(set(list(y))))
    MAX = max(tmp, MAX)

print(MAX)

Solution (Python):
a =int(input())
s = input()
r = 0
m = 0
for i in range(1,a):
    tmp = s[0:i]
    temp = s[i:a]
    tm = set(tmp)
    tp = set(temp)
    for i in tm:
        for j in tp:
            if i == j:
                r +=1
    if m < r:
        m = r
    r = 0
    
print(m)

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


if __name__ == '__main__':
    main()

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

Solution (Python):
from statistics import mean, median,variance,stdev
import sys
import math
import fractions
def j(a):
    if a==1: print("Yes")
    else :print("No")


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())

x = ip()                              




a = input()                                  

l = []
for i in range(len(a)):
    l.append(a[i])
x = l
max = 0
for i in range(1,len(x)):
    c = x[:i]
    d = x[i:]
    c.sort()
    d.sort()
    c = set(c)
    d = set(d)
    num = len(c & d)
    if num > max: max = num
print(max)

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

max_count = -1
max_index = -1
for i in range(N) :
    c1 = cl.Counter(list(S[0:i]))
    c2 = cl.Counter(list(S[i:]))
    if (len(c1.keys() & c2.keys()) > max_count) :
        max_count = len(c1.keys() & c2.keys())
        max_index = i

print(max_count)

Solution (Python):
n = int(input())
s = input()
ans = 0
for i in range(1,n):
  a = set([j for j in s[:i]])
  b = set([k for k in s[i:]])
  c = a & b
  d = len(c)
  if d > ans:
    ans = d    
print(ans)

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

left = {}
right = {}

for c in S[1:]:
    if c not in right:
        right[c] = 1
    else:
        right[c] += 1

left[S[0]] = 1

ans = len(left.keys() & right.keys())
for i in range(1, N-1):
    c = S[i]
    if c not in left:
        left[c] = 1
    
    if right[c] == 1:
        del(right[c])
    else:
        right[c] -= 1

    ans = max(ans, len(left.keys() & right.keys()))
    

print(ans)

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

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

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

ans = 0

for i in range(n):
    x = set(s[:i+1])
    y = set(s[i+1:])

    z = 0
    for w in x:
        if w in y:
            z +=1
    if z > ans:
        ans = z
print(ans)

Solution (Python):
n=int(input())
S=input()
count1=0
m=0
for i in range(1,n):
    x=S[:i]
    y=S[i:]
    x1=list(x)
    x2=set(x1)
    for i in x2:
        if y.count(i)>=1:
            count1+=1
    m=max(count1,m)
    count1=0
    x=""
    y=""
    x1=[]
    x2=[]
print(m)

Solution (Python):
a = int(input())
b = list(input())
cr = []
for i in range(1,a):
    count = 0
    br = set(b[0:i])
    for r in br:
        if r in b[i:a]:
            count += 1
    cr.append(count)
print(max(cr))

Solution (Python):
N = int(input())
SList = list(input())
max = 0
i = 0
while i < N-1:
    left = SList[0:i+1]
    right = SList[i+1:N]
    common = list(set(left)&set(right))
    l = len(common)
    if max < l:
        max=l
    i += 1

print(max)

Solution (Python):
N = int(input())
S = str(input())
slist = list(S)
max = 0
i = 0
while i < N:
  left = slist[0:i+1]
  right = slist[i+1:N]
  common = list(set(left) & set(right))
  l = len(common)
  if max <= l:
    max = l
  i+=1
print(max)

Solution (Python):
import numpy as np

N = int(input())
S = input()
alphabet = "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z".split(",")

ans = 0
max_num = 0
for n in range(N):
    s1 = S[:n]
    s2 = S[n:]

    h1 = np.zeros(26)
    h2 = np.zeros(26)

    for i in range(len(s1)):
          h1[alphabet.index(s1[i])] = 1
    for i in range(len(s2)):
          h2[alphabet.index(s2[i])] = 1

    h = h1 * h2
    num = np.sum(h)
    if num > max_num:
          max_num = num

print(int(max_num))

Solution (Python):
_ = input()
s = input()
ans = 0
for i in range(len(s)):
  s1 = set(s[:i])
  s2 = set(s[i:])
  c = 0
  for j in s1:
    if j in s2:
      c = c + 1
    ans = max(c, ans)
    
print(ans)

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

Solution (Python):
from collections import OrderedDict 



def removeDupWithoutOrder(str): 
   
    
    
    
    
    
    
    
    return "".join(set(str)) 
  


def removeDupWithOrder(str): 
    s = "".join(OrderedDict.fromkeys(str)) 
    return "".join(sorted(s))

n = int(input())
s = input()
maxcnt = 0
oset = set()
for i in range(1,n):
    s1 = removeDupWithOrder(s[0:i])
    s2 = removeDupWithOrder(s[i:n])
    oset.add(s1+' '+s2)
ls = list(oset)
for x in ls:
    s1,s2 = map(str,x.split())
    cnt = 0
    for i in range(len(s1)):
        if s1[i] in s2:
            cnt += 1
    if maxcnt < cnt:
        maxcnt = cnt
print(maxcnt)

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

Solution (Python):
a=int(input())
b=list(input())
c=[]
h=[]
for k in range(0,a-1):
	d=[]
	c.append(b[k])
	for i in range(k+1,a):
		d.append(b[i])


	e=[]
	for i in c:
		if i not in e:
			e.append(i)


	f=[]
	for i in d:
		if i not in f:
			f.append(i)


	g=0
	for l in range(len(e)):
		for i in range(len(f)):
			if e[l]==f[i]:
				g=g+1
	h.append(g)

print(max(h))

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

ans=0
for i in range(1,a):

  seta=set(s[:i])
  setb=set(s[i:])
  setc=seta & setb
  if ans < len(setc):
    ans=len(setc)
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):
def ToSet(S):
    set_S = set()
    for s in S:
        set_S.add(s)
    return set_S

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

    m = 0
    for i in range(1, n):
        set1 = ToSet(s[0:i])
        set2 = ToSet(s[i:])
        l = len(set1 & set2)
        if m < l: 
            m = l
    print(m)

if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
s = input()
al = [chr(ord('a') + i) for i in range(26)]
ans = 0
for i in range(n - 1):
    sh = 0
    for j in al:
        if j in s[0:i+1] and j in s[i+1:n]:
            sh += 1
    if sh > ans:
        ans = sh
print(ans)

Solution (Python):
N = int(input())
s = input()
L = []
for i in range(N):
  A = set(s[:i])
  B = set(s[i:])
  L.append(len(A&B))
print(max(L))

Solution (Python):
N = int(input())
S = input()
ans = 0
for i in range(N - 1):
    count = 0
    table = {}
    for s in S[:i]:
        if s in S[i:]:
            table[s] = 1
    ans = max(ans, sum([1 for _ in table.keys()]))
print(ans)

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

intger2 = 0
c = []

for i in range(N):
  intger1 = 0
  str1 = list(set(S[i + 1:]))
  str2 = list(set(S[:i + 1]))
  l = len(str2)
  
  for j in range(l):
    if( str2[j] in str1):
      intger1 += 1
      
    else:
      continue
  
  if( intger2 <= intger1):
    intger2 = intger1
    c.append(intger2)
    
  else:
    continue

print(max(c))

Solution (Python):
N = int(input())
S = list(input())
ans = 0
for i in range(1,N+1):
    ANS = []
    ANSB = []
    b = 0
    for k in range(i):
        ANS.append(S[k])
    ANS = list(set(ANS))
    for k in range(i,N):
        ANSB.append(S[k])
    ANSB = list(set(ANSB))
    for k in ANSB:
        if k in ANS:
            b += 1
    ans = max(ans,b)
print(ans)

Solution (Python):
n = int(input()) - 1
s = input()
result_list = list()
for i in range(n):
    x = s[:i+1]
    y = s[i+1:]
    comon_set_len = len(set(ii for ii in x) & set(iii for iii in y))
    result_list.append(comon_set_len)
result_list.sort(reverse = True)
print(result_list[0])

Solution (Python):
n = int(input())
s = input()
ans = 0
for i in range(n):
    a = list(set(s[:i]))
    b = list(set(s[i:]))
    l_a = len(a)
    l_b = len(b)
    c = list(set(a+b))
    l_c = len(c)
    ans = max(ans,l_a+l_b-l_c)
print(ans)

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

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

print(res)

Solution (Python):
class CutAndCount:
    def __init__(self, n, s):
        self.n = n
        self.s = s

    def cut_and_count(self, i):
        chars_contained_both = 0

        x, y = s[0:i], s[i:]
        for c_in_x in set(x):
            for c_in_y in set(y):
                if c_in_x == c_in_y:
                    chars_contained_both += 1

        return chars_contained_both

    def solve(self):
        max_chars = 0

        for i in range(1, self.n):
            max_chars = max(self.cut_and_count(i), max_chars)

        print(max_chars)

n, s = int(input()), input()
cac = CutAndCount(n, s)
cac.solve()

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

result = max(sum(c in S[i:] for c in set(S[:i])) for i in range(N))

print(result)

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

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

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

print(ans)

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

S = input()

ans_L = []
for i in range(1, len(S) + 1):
    A = S[0:i + 1]
    B = S[i + 1:]
    l = set()
    for j in A:
        if j in B:
            l.add(j)
    ans_L.append(l)

ans = []
for i in ans_L:
    ans.append(len(i))
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):
N = int(input())
S = list(map(str,input()))
l = []
for i in range(N):
  S_2 = set(S[:i]) 
  S_3 = set(S[i:]) 
  l.append(len(list(S_2 & S_3)))
print(max(l))

Solution (Python):
n = int(input())
s = input()
ans = 0
for i in range(1, n):
    s2 = set(s[:i])
    count = 0
    for j in s2:
        if j in s[i:n]:
            count += 1
    if count > ans:
        ans = count

print(ans)

Solution (Python):
from collections import Counter

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

ans = 0

for i in range(1, n-1):
    count = 0
    x = s[0:i+1]
    y = s[i+1:]
    cx = Counter(x)
    cy = Counter(y)
    for key, value in cx.items():
        if cy[key] > 0:
            count += 1
    ans = max(ans, count)

print(ans)

Solution (Python):
N = int(input())
S = input()
P = []
for i in range(0,N-1) :
    L1 = list(S[:i+1])
    L2 = list(S[i+1:])
    L1 = list(set(L1))
    L2 = list(set(L2))
    p = 0
    for j in range(len(L1)) :
        p += L2.count(L1[j])
    P.append(p)
print(max(P))

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

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

sys.setrecursionlimit(10**5)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
s = lc()

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

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

ans=[]
for sikiri in range(n):
    l=list(set(s[:sikiri]))
    r=list(set(s[sikiri:]))
    ans.append(len(l) + len(r) - len(set(l+r)))

print(max(ans))

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

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

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

s1 = []
s2 = []

for i in range(n):
  s1.append([])
  s2.append([])

for i in range(n):
  for j in range(n):
    if j < i:
      s1[i].append(t[j])
    else:
      s2[i].append(t[j])

count = 0
com = []
slv = []
      
for i in range(n):
  for j in range(i):
    if s1[i][j] in s2[i] and s1[i][j] not in com:
      count += 1
      com.append(s1[i][j])
  slv.append(count)
  count = 0
  com = []
  
print(max(slv))

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

ans = 0
for i in range(1, n):
    x1 = set(s[:i])
    x2 = set(s[i:])
    ans_cur = 0
    for xx1 in x1:
        if xx1 in x2:
            ans_cur +=1
    ans = max(ans, ans_cur)
print(ans)

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

res = 0
for i in range(N):
	X = set(list(S[:i + 1]))
	Y = set(list(S[i + 1:]))
	c = 0
	for x in X:
		if x in Y:
			c += 1
	if res < c:
		res = c
print res

Solution (Python):
n=int(input())
s=input()
same=-1
for i in range(0,n):
  left=s[:i]
  right=s[i:]
  same_tmp=0
  while len(left)>0 and len(right)>0:
    char=left[0]
    if char in right:
      same_tmp+=1
      left=left.replace(char,'')
      right=right.replace(char,'')
    else:
      left=left.replace(char,'')
    left.replace(char,'')
  if same_tmp>same:
    same=same_tmp
print(same)

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

Solution (Python):
n=int(input())
s=input()
ctl=[]
ctr=[]
for i in range(26):
  ctl.append(0)
  ctr.append(0)
for i in range(n):
  ctr[ord(s[i])-ord('a')]+=1
ans=0
for i in range(n-1):
  ctr[ord(s[i])-ord('a')]-=1
  ctl[ord(s[i])-ord('a')]+=1
  ans1=0
  for j in range(26):
    if(ctl[j]>0 and ctr[j]>0):
      ans1+=1
  ans=max([ans, ans1])
print(ans)

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

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

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

count = 0
for i in range(1, N-1):
    A = list(set(S[:i]))
    B = list(set(S[i:]))
    C = 0
    for a in A:
        if a in B:
            C += 1
    if count < C:
        count = C

print(count)

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

Solution (Python):
def run(N, S):
    ret = 0
    for i in range(1, N-1):
       ret = max([ret, num_dup(N, S, i)])
    return ret


def num_dup(N, S, x):
    '''
    0 < x < N-1
    '''
    s1 = list(set(S[:x]))
    s2 = list(set(S[x:]))
    cnt = 0
    for ss in s1:
        if ss in s2:
            cnt += 1
    return cnt

def main():
    N = int(input())
    S = input()
    print(run(N, S))


if __name__ == '__main__':
    main()

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

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

X = 0

for i in range(N):
	x = 0
	a = S[:i]
	b = S[i:]

	for j in range(26):
		if al[j] in a and al[j] in b:
			x += 1
	if x >= X:
		X = x

print(X)

Solution (Python):
_=input ()
s=input ()
sr=[ss for ss in s if s.count (ss) >1 ]
a=0
for i in range(len(sr)):
  a=max(len(set(sr[:i+1]) & set(sr[i+1:])),a)
print (a)

Solution (Python):


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

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

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

Solution (Python):
n = int(input())
s = input()
num = []
for i in range(n):
  a = set(s[:i])
  b = set(s[i:])
  num.append(len(a.intersection(b)))
print(max(num))

Solution (Python):
n = int(input()) - 1
s = input()
result_list = list()
for i in range(n):
    x = s[:i+1]
    y = s[i+1:]
    comon_set_len = len(set(ii for ii in x) & set(iii for iii in y))
    result_list.append(comon_set_len)
result_list.sort(reverse = True)
print(result_list[0])

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())
l = [0]*n
for i in range(n):
    s1 = set(s[:i:])
    s2 = set(s[i::])
    l[i] = len(s1&s2)
print(max(l))

Solution (Python):
n = int(input())
s = list(input())
a = {}
b = {}
c = []
for i in range(n):
  a = set(s[:i+1])
  b = set(s[i+1:])
  c.append(len((a&b)))
  a.clear()
  b.clear()
print(max(c))

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

max = 0
i = 1
while i < N:
    left = {c for c in w[:i]}
    right = {c for c in w[i:]}
    x = len(left & right)
    if x > max:
        max = x
    i += 1
print(max)

Solution (Python):
from collections import Counter as C
n = int(input())
s = input()

res = 0
for i in range(1,n):
    a = s[:i]
    b = s[i:]
    tmp = 0
    for k in C(a):
        if k in b:
            tmp += 1
    res = max(res,tmp)
print(res)

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

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

m = 0
for i in range(1,N):
    m = max(m, len(set(list(S[:i])).intersection(set(list(S[i:])))))
print(m)

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

for _ in range(1, N):
  a = set(S[:_])
  b = set(S[_:])
  n = len(a & b)
  if ans < n:
    ans = n

print(ans)

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

print(maxnum)

Solution (Python):
def count_(X,Y):
    dic={}
    for a in X:
        if a in Y:
            dic[a]=1
    return len(dic)

N=input()
S=input()
max_=0
for i in range(1,len(S)):
    X=S[:i]
    Y=S[i:]
    tmp = count_(X,Y)
    if tmp>max_:
        max_=tmp
print(max_)

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

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

Solution (Python):
N = int(input())
S = list(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()


def countletter(T):
    S=[]
    for t in T:
        if t not in S:
            S.append(t)
    return len(S)

ans=0

for i in range(1,N):
    A=S[:i]
    B=S[i:]
    
    ans=max(ans,countletter(A)+countletter(B)-countletter(S))
    
print(ans)

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

Solution (Python):
n = int(input())
s = list(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 = list(str(input()))

maxcha = 0
for i in range(n):
    left = set(s[:i])
    right = set(s[i:])
    now = len(left & right)
    maxcha = max(maxcha,now)
    

print(maxcha)

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

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

Solution (Python):
n = int(input())
s = input()
ans = 0
for i in range(1, n):
    num = 0
    for c in range(ord('a'), ord('z')+1):
        if (chr(c) in s[:i] and chr(c) in s[i:]):
            num += 1
    ans = max(ans, num)
print(ans)

Solution (Python):
n = int(input())
s = str(input())
list_s = list(s)
cut = 0
ans = 0
while cut < n:
    if ans < len(set(list_s[:cut]) & set(list_s[cut:])):
        ans = len(set(list_s[:cut]) & set(list_s[cut:]))
    cut += 1
print(ans)

Solution (Python):
n = int(input())
s = input()
x = 0
for i in range(1,n):
    count=0
    for j in "abcdefghijklmnopqrstuvwxyz":
        if j in s[0:i] and j in s[i:n]:
            count += 1
        if count > x:
            x = count
print(x)

Solution (Python):
from sys import stdin

N = int(stdin.readline().rstrip())
S = stdin.readline().rstrip()

cut = 1
ans = 0

for i in range(cut, len(S) - 1):
    left = []
    right = []

    for c in range(len(S)):
        if (c < i):
            left.append(S[c])
        else:
            right.append(S[c])

    all_len = len(set(left) & set(right))
    if (all_len > ans):
        ans = all_len

print(ans)

Solution (Python):
n = int(input())
s = str(input())
m = 0
for i in range(1,n):
  count = 0
  for j in "abcdefghijklmnopqrstuvwxyz":
    if j in s[0:i] and j in s[i:n]:
      count += 1
  if count > m:
    m = count
print(m)

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

alphabet = list("abcdefghijklmnopqrstuvwxyz")

def clear_dict(dict, keys):    
    for char in keys:
        dict[char] = 0

max_cnt = 0
for char_n in range(1, len(s)):
    cnt_left = dict()
    cnt_right = dict()
    clear_dict(cnt_left, alphabet)
    clear_dict(cnt_right, alphabet)

    str_left = s[:char_n]
    str_right = s[char_n:]
    for char in str_left:
        cnt_left[char] += 1
    for char in str_right:
        cnt_right[char] += 1
    
    cnt = 0
    for char in alphabet:
        if cnt_left[char] != 0 and cnt_right[char] != 0:
            cnt += 1
    
    max_cnt = max(cnt, max_cnt)

print(max_cnt)

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

S_rev = S[::-1]
for i in range(N):
    count = 0
    for c in set(S[:i]):
        if c in S_rev[:-i]:
            count += 1
    max_cnt = max(max_cnt, count)

print(max_cnt)

Solution (Python):
n=int(input())
s=list(input())
a=[]
for i in range(n-1):
  x=[s[j] for j in range(i+1)]
  y=[s[k] for k in range(i+1,n)]
  x=list(set(x))
  c=0
  for l in x:
    if l in y:c+=1
  a.append(c)
print(max(a))

Solution (Python):
N = int(input())
s = input()
L = []
for i in range(N):
  A = set(s[:i])
  B = set(s[i:])
  L.append(len(A&B))
print(max(L))

Solution (Python):
n = int(input())
s = input()
num = 0
for i in range(1, n):
    q = s[:i]
    p = s[i:]
    tmp1 = set()
    for j in q:
        tmp1.add(j)
    tmp2 = set()
    for j in p:
        tmp2.add(j)

    num = max(num, len(tmp1 & tmp2))

print(num)

Solution (Python):
N = int(input())
S = input()
l = []
for i in range(len(S)-1):
  X = S[:i+1] 
  Y = S[i+1:]
  X_and_Y_count = len(set(X) & set(Y))
  l.append(X_and_Y_count)
  if i == len(S)-2:
    print(max(l))

Solution (Python):

n = int(input())
s = input()
print(max([ len(set(s[: i]).intersection(set(s[i :]))) for i in range(n + 1) ]))

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


def get_common_chars(first_set, latter_set):
    common_chars = set([])
    for chara in first_set:
        if chara in latter_set:
            common_chars.add(chara)
    return common_chars


max_charlen = 0
for i in range(n - 1):
    first_set = set(s[:i + 1])
    latter_set = set(s[i + 1:])
    common_charlen = len(get_common_chars(first_set, latter_set))
    if max_charlen < common_charlen:
        max_charlen = common_charlen
print(max_charlen)

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

res = []

for i in range(1, len(S)):
    a = S[:i]
    b = S[i:]
    c = set(a) & set(b)
    res.append(len(c))

print(max(res))

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

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

ans = 0

for i in range(1, N):
    x = S[:i]
    y = S[i:N]

    cnt = 0

    for j in range(ord('a'), ord('z') + 1):
        if chr(j) in x and chr(j) in y:
            cnt += 1
    ans = max(ans, cnt)

print(ans)

Solution (Python):
n = int(input())
s = list(input())
maxC=0
index=0
while index<n:
    list1=[]
    list2=[]
    listForChar=[]
    index2=0
    sum=0
    while index2<index+1:
        list1.append(s[index2])
        index2+=1
    index3=index+1
    while index3<n:
        list2.append(s[index3])
        index3+=1
    for char in list1:
        if char in list2 and char not in listForChar:
            sum +=1
            listForChar.append(char)
    if sum>maxC:
        maxC=sum
    index+=1
print(maxC)

Solution (Python):


INF = float('inf')


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

ans = 0
for i in range(1, N - 1):
    str_list = []
    score = 0

    for x in S[:i]:
        if x not in str_list: str_list.append(x)

    for xi in str_list:
        if xi in S[i:]: score += 1

    ans = max(ans, score)

print(ans)