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

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

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

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


def check_list_element(list):
    a = []
    for i in list:
        if i not in a:
            a.append(i)
    return a


for i in range(n):
    count = 0
    a = s[:i]
    b = s[i:]
    a = check_list_element(a)
    for j in range(len(a)):
        if a[j] in b:
            count += 1
    if count >= max_num:
        max_num = count


print(max_num)

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

Solution (Python):
n=int(input())
s=input()
dic={}
for i in set(list(s)):
    if s.count(i)>1:
        dic[i]=s.count(i)


d=0
for i in range(n-1):
    c=0
    x=s[:i+1]
    y=s[i+1:]
    if len(y)>len(x):
        for j in dic:
            if x.count(j)!=dic[j] and x.count(j)>0:
                c+=1
    else:
        for j in dic:
            if y.count(j)!=dic[j] and y.count(j)>0:
                c+=1
    if c>d:
        d=c
        

print(d)

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

    ans = 0
    for i in range(1,N):
        L = list(set(S[:i]))
        R = list(set(S[i:]))
        cnt = 0
        for l in L:
            if l in R:
                cnt += 1
        ans = max(ans, cnt)
    print(ans)

main()

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

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

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

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

Solution (Python):
import collections

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

ans = 0
for i in range(1, len(S)):
  right = collections.Counter(S[:i])
  left = collections.Counter(S[i:])
  n = right.keys() & left.keys()
  if (len(n) > ans):
    ans = len(n)
print(ans)

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

Solution (Python):
N = int(input())
s = input()
num_list = []
for i in range(N):
  l_s = s[:i]
  r_s = s[i:]
  num = len(set(l_s).intersection(set(r_s)))
  num_list.append(num)
print(max(num_list))

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

count_max = 0

for i in range(1,N):
    count = 0
    S_tmp = []
    for j in range(0,i):
        count_S = S_tmp.count(S[j])
        if count_S == 0:
            S_tmp.append(S[j])
            for k in range(i,N):
                if S[j] == S[k]:
                    count += 1
                    break
    if count_max < count:
        count_max = count

print(count_max)

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

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

ans=0
sset=set()
for i in range(1,N):
    sset.clear()
    num=0
    s1=S[:i]
    s2=S[i:]
    for j in range(i):
        sset.add(s1[j])
    for c in list(sset):
        if c in s2:
            num+=1
    if ans<num:
        ans=num

print(ans)

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

m = 0
for i in range(1,len(s)):
    x = s[0:i]
    y = s[i:len(s)]
    a = []
    count = 0
    for j in range(0,i):
        if x[j] in y and not(x[j] in a):
            a.append(x[j])
            count += 1
    m = max(m,count)
print(m)

Solution (Python):
n=int(input());s=input()
l=[[0]*26 for i in range(n-1)]
r=[[0]*26 for i in range(n-1)]

for i in range(n-1):
  l[i][ord(s[i])-ord('a')]=1
  if i!=n-2:
    for j in range(26):
      l[i+1][j]=l[i][j]

for i in range(n-2,-1,-1):
  r[i][ord(s[i+1])-ord('a')]=1
  if i!=0:
    for j in range(26):
      r[i-1][j]=r[i][j]

lr=[[0]*26 for i in range(n-1)]
for i in range(n-1):
  for j in range(26):
    lr[i][j]=l[i][j]*r[i][j]
x=0
for i in range(n-1):
  x=max(x,sum(lr[i]))
print(x)

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

for i in range(1,n):
    a = set(s[:i])
    b = set(s[i:])
    cnt = 0
    for a_ in a:
        cnt += 1 if a_ in b else 0
    max_cnt = max(cnt,max_cnt)

print(max_cnt)

Solution (Python):
n = int(input())
s = input()
can = []
for cut in range(n):
  p = []
  for i in range(cut+1):
    now = s[i]
    if now in p:
      pass
    else:
      p.append(now)
  pp = []
  for i in range(cut+1,n):
    now = s[i]
    if now in p:
      if now in pp:
        pass
      else:
        pp.append(now)
    else:
      pass
  can.append(len(pp))
print(max(can))

Solution (Python):
from collections import Counter

N = int(input())
S = list(input())
ans = 0
for i in range(N):
    L = list(Counter(S[:i]).keys())
    R = list(Counter(S[i:]).keys())
    c = 0
    for l in L:
        if l in R:
            c += 1
    ans = max(ans, c)
print(ans)

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

ans = 0
a = 0
n = 0
for i in range(1,N):
    X = S[:i]
    Y = S[i:]
    lis = list(set(X))
    for j in range(len(lis)):
        if Y.count(lis[j]) != 0:
            a += 1

    if a > ans:
        ans = a
    a = 0

print(ans)

Solution (Python):
b = int(input())
a = input()
mc = 0
for i in range(1, len(a)):
    b = a[:i]
    c = a[i:]
    d = {}
    e = []
    cnt = 0
    for j in range(len(b)):
        d[b[j]] = 1
    for j in range(len(c)):
        if c[j] in d and c[j] not in e:
            cnt += 1
            e.append(c[j])
    mc = max(mc, cnt)
print(mc)

Solution (Python):
n = int(input())
s = [c for c 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()
a = 0

for L in range(N):
  left = S[:L]
  right = S[L:]
  both = set(left)&set(right)
  a = max(a,len(both))

print(a)

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

ans = []
for i in range(1, n):
    set_a = set(s[:i])
    set_b = set(s[i:n+1])
    ans.append(len(set_a & set_b))

print(max(ans))

Solution (Python):
N = int(input())
S = input()
ans = 0
for i in range(1,N):
    count = 0
    X = ""
    Y = ""
    for j in S[:i]:
        X += j

    for k in S[i:]:
        if X.find(k) != -1 and Y.find(k) == -1:
            Y += k
            count += 1
 
    ans = max(count, ans)

print(ans)

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

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

Solution (Python):
n=int(input())
s=input()
cnt=0
ans=[]
for i in range(n):
	a=s[:i]
	b=s[i:]
	l=[]
	cnt=0
	for j in range(len(a)):
		if b.count(a[j])>=1\
		and a[j] not in l:
			cnt+=1
			l.append(a[j])
	ans.append(cnt)
print(max(ans))

Solution (Python):
N = int(input())
S = input()
ans_list = []
for i in range(1, N):
    tmp = 0
    A = list(set(S[0:i]))
    B = list(set(S[i:N]))
    for k in A:
        if k in B:
            tmp += 1   
    ans_list.append(tmp)
print(max(ans_list))

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


print(ans)

Solution (Python):
n = int(input())
s = list(input())
intersec = [] 
for i in range(n):
  w = set(s[0:1+i])
  x = set(s[1+i:])
  intersec.append(len(w & x))


print(max(intersec))

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

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

max_score = 0
for cut in range(1, n-2):
    bh = set(s[:cut])
    lh = set(s[cut:])
    cscore = len(bh.intersection(lh))
    if max_score < cscore:
        max_score = cscore

print(max_score)

Solution (Python):
from collections import Counter

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

solver = []
for i in range(N-1):
  X = S[:i+1]
  Y = S[i+1:]
  lst_X = list(Counter(X).keys())
  lst_Y = list(Counter(Y).keys())
  lst_and = set(lst_X) & set(lst_Y)
  solver.append(len(lst_and))
  
print(max(solver))

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

ans = []

for i in range(len(s)-1):
    dic = {}
    for j in range(i+1):
        if s[j] in s[i+1:] and s[j] not in dic:
            dic[s[j]] = 1
    ans.append(len(dic))

print(max(ans))

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

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

ans = 0
for i in range(1, N):
    sj = set()
    sk = set()
    for j in range(i):
        sj.add(S[j])
    for k in range(i, N):
        sk.add(S[k])
    ans = max(len(sj & sk), ans)
    
print(ans)

Solution (Python):
n = int(input())
s = list(input())
li = []
for i in range(1,n-1):
    li.append(len(set(s[:i+1]) & set(s[i+1:])))
print(0 if len(li) == 0 else max(li))

Solution (Python):

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

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

Solution (Python):

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

max_t = 0
for i in range(1, n):
    s1 = set(s[:i])
    s2 = set(s[i:])
    t = len(s1.intersection(s2))
    max_t = max(max_t, t)
print(max_t)

Solution (Python):

N = int(input())
S = input()
S = [c for c in S]


ans = 0
for i in range(N - 1):
    first = set(S[0:i+1])
    second = set(S[i+1:])
    
    
    tmpans = 0
    for index, n in enumerate(range(len(first))):
        if list(first)[index] in list(second):
            tmpans += 1
            ans = max(ans, tmpans)


print(ans)

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

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

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

Solution (Python):
N = int(input())
S = list(input())
ans_lsit = []
for i in range(N):
    count = 0
    tmp = list(set(S[:i]))
    for j in range(len(tmp)):
        if tmp[j] in S[i:]:
            count += 1
    ans_lsit.append(count)

ans = max(ans_lsit)
print(ans)

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

Solution (Python):
N = int(input())
S = list((x.encode()[0] - "a".encode()[0] for x in input()))
alb = [-1] * 26
ala = [-1] * 26
Sc = [0] * (len(S)+1)
for i, c in enumerate(S):
    if alb[c] == -1:
        alb[c] = i+1
        Sc[alb[c]] += 1
    else:
        if ala[c] >= 0:
            Sc[ala[c]] += 1
        ala[c] = i+1
        Sc[ala[c]] -= 1

for i, v in enumerate(ala):
    if v == -1 and alb[i] >= 0:
        Sc[alb[i]] -= 1

x = 0
m = 0
for c in Sc[:N]:
    x += c
    m = max(x, m)

print(m)

Solution (Python):

n = input()
s = input()
res = 0
for pos in range(len(s)):
    s1 = set(s[0:pos])
    s2 = set(s[pos:])
    s3 = s1 & s2
    res = max(res, len(s3))

print(res)

Solution (Python):
n = int(input())
s = input()
mx = 0
for i in range(n-1):
  a = [ord(aa) for aa in s[:i+1]]
  b = [ord(bb) for bb in s[i+1:]]
  counter = 0
  for c in range(ord('a'), ord('z')+1):
    if (c in a) and (c in b):
      counter += 1
  if mx < counter:
    mx = counter

print(mx)

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

ans = 0
for i in range(1,N-1):
    X = set(S[:i])
    Y = set(S[i:])
    tmp = 0
    for j in X:
        if j in Y:
            tmp += 1
    ans = max(ans,tmp)

print(ans)

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


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

ans = 0
for i in range(1, n):
    count = 0
    for j in az:
        if s[i:n].count(j) != 0 and s[:i].count(j) != 0:
            count += 1
    ans = max(ans, count)
print(ans)

Solution (Python):
N = int(input())
S = input()
if N == 2:
    print(len(set(S[0]).intersection(set(S[1]))))
else:
    ans = []
    for i in range(1, N-1):
        a = set(S[:i])
        b = set(S[i:])
        ans.append(len(a.intersection(b)))
    print(max(ans))

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

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

for i in range(N - 1):
    ansCnt = 0
    tmpX = "".join(set(S[0:i + 1]))
    tmpY = "".join(set(S[i + 1:]))

    for j in range(len(tmpX)):
        if tmpY.count(tmpX[j]) == 1:
            ansCnt += 1

    ansMax = max(ansMax, ansCnt)

print(ansMax)

Solution (Python):
N = int(input())
S = input()
ans = 0
for i in range(1, N):
  left = S[:i]
  right = S[i:]
  cnt = 0
  both = []
  for j in range(len(right)):
    if right[j] in left and not right[j] in both:
      cnt += 1
      both.append(right[j])
  ans = max(ans, cnt)
print(ans)

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

Solution (Python):
a = int(input())
b = list(input())
c = 0
for i in range(a):
    d = {}
    e = {}
    for j in range(0, min(i+1, a)):
        if b[j] not in d:
            d[b[j]] = 1
    for j in range(i+1, a):
        if b[j] in d and b[j] not in e:
            e[b[j]] = 1

    c = max(c, len(e))
print(c)

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')


def A():
    a, b = LI()
    print(max(a + b, a - b, a * b))
    return


def B():
    n = II()
    s = S()
    ans = 0
    for i in range(n + 1):
        s1 = list(set(s[i:]))
        s2 = list(set(s[:i]))
        b = 0
        for si in s1:
            b += si in s2
        ans = max(ans, b)
    print(ans)
    return


def C():
    n = II()
    s = S()
    dp = [0 for i in range(n)]
    for num,si in enumerate(s):
        if si == "E":
            dp[num] = dp[num-1]+1
        else:
            dp[num] = dp[num - 1]
    ans = float("INF")
    a = max(dp)
    for i in range(n):
        ans = min(ans,  a - dp[i] + i - dp[i] + (s[i] == "E"))
    
    print(ans)
    return


def D():
    return




if __name__ == '__main__':
    B()

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 = list(input())
r = []
for i in range(1,n):
  l,u = [], []
  for j in range(n):
    if j < i:
      l.append(s[j])
    else:
      u.append(s[j])
  c = 0
  for k in l:
    if k in u:
      u = [t for t in u if t != k]
      c += 1
  r.append(c)
print(max(r))

Solution (Python):



N = int(input())
S = list(input())
a1 = []
a2 = []
duplicate = []
max_num = 0

for i in range(1, N):
    a1 = S[0:i]
    a2 = S[i::]
    duplicate = [x for x in set(a1) if a2.count(x) >= 1]
    if len(duplicate) > max_num: 
        max_num = len(duplicate)
print(max_num)

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

N = INT()
S = input()
l = []
for i in range(1, N):
    a = S[0:i]
    b = S[i:]
    a_set = set(a)
    b_set = set(b)
    
    c = a_set & b_set
    l.append(len(c))
print(max(l))

Solution (Python):
N = int(input())
S = list(input())
r = []
c = 0
for x in range(N):
  a = S[:x]
  b = S[x:]

  for y in set(a):
    if y in b:
      c += 1
  r.append(c)
  c = 0
print(max(r))

Solution (Python):
N = int(input())
S = list(input())
r = []
c = 0
for x in range(N):
  a = S[:x]
  b = S[x:]
  if len(a) >= 1 and len(b) >= 1:
    for y in set(a):
      if y in b:
        c += 1
    r.append(c)
  c = 0
print(max(r))

Solution (Python):
n = int(input())
s = list(input())
ans = [i * 0 for i in range(100)]
if n == 2:
    ans.clear()
    if s[0] == s[1]:
        ans.append(1)
    else:
        ans.append(0)
else:
    for i in range(0,n-1):
        tmp1 = list(set(s[:i]))
        tmp2 = list(set(s[i:]))
        for j in range(len(tmp1)):
            if tmp1[j] in tmp2:
                ans[i] += 1
print(max(ans))

Solution (Python):
a = int(input())
b = input()
ans = 0
for i in range(1, a-1):
    c = b[:i]
    d = b[i:]
    e = 0
    f = []
    for j in range(len(c)):
        for k in range(len(d)):
            if c[j] == d[k] and c[j] not in f:
                e += 1
                f.append(c[j])
                break
    ans = max(ans, e)
print(ans)

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

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

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

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

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

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

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

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

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()
ans = 0
for i in range(n):
    x = len(set(s[:i]) & set(s[i:]))
    if x > ans:
        ans = x
    if ans > n // 2:
        break
print(ans)

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

pre={}
back={}

for i in range(len(S)):
    n = pre.get(S[i], 0)
    n = n+1
    pre[S[i]] = n

ans = 0
for i in range(len(S)):
    n = pre[S[i]]
    if(n > 1):
        pre[S[i]] = n-1
    else:
        pre.pop(S[i])
    back[S[i]] = back.get(S[i], 0) + 1
    c = [x for x in list(pre.keys()) if x in list(back.keys())]
    ans = max(ans,len(c))

print(ans)

Solution (Python):
n=int(input())
s = str(input())
ans=0
for i in range(n):
    s1=set(s[:i])
    s2=set(s[i:])
    tmp=len(s1&s2)
    if tmp>ans:ans=tmp
print(ans)

Solution (Python):
N = int(input())
S = input()
count = 0
for i in range(2, N-1):
    left = set(S[0:i])
    right = set(S[i:])
    num = len(left & right)
    if num > count:
        count = num
print(count)

Solution (Python):
from functools import reduce
import math

def main():
    
    
    
    

    
    
    
    
    
    

    
    

    
    
    
    
    
    
    
    
    
    INF = float("inf")

    
    MOD = 10**9+7
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

    
    
    
    
    N = int(input())
    S = list(_ for _ in input())
    max_S = 0
    for i in range(N):
        S1 = set(S[0:i])
        S2 = set(S[i:N])
        max_S = max(max_S,len(S1.intersection(S2)))
    print(max_S)
    
if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
S = input()
counters = []
for i in range(0, 26):
	counters.append(0)
for i in range(0, N):
	counters[ord(S[i])-97] += 1
R = counters
L = []
for i in range(0, 26):
	L.append(0)
max = 0
for i in range(0, N):
	R[ord(S[i])-97] -= 1
	L[ord(S[i])-97] += 1
	cnt = 0
	for j in range(0, 26):
		if R[j] != 0 and L[j] != 0:
			cnt += 1
	if max < cnt:
		max = cnt
print(max)

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

largest_size_intersection = 0
for split in range(N):
    left = set(S[:split])
    right = set(S[split:])
    largest_size_intersection = max(largest_size_intersection, len(left.intersection(right)))
print(largest_size_intersection)

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

answer = 0
for L in range(N):
  left = S[:L]
  right = S[L:]
  both = set(left) & set(right)
  answer = max(answer, len(both))

print(answer)

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

ans = 0
for i in range(n-1):
    tmp = []
    cnt = 0
    for j in range(i+1):
        if s[j] not in tmp:
            tmp.append(s[j])
    for j in range(i+1,n):
        if s[j] in tmp:
            cnt += 1
            tmp.remove(s[j])
    if ans < cnt:
        ans = cnt
print(ans)

Solution (Python):


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

ls = []
for i in range(n):
  ls.append([set(s[:i]),set(s[i:])])

n_ls = [len(i[0] & i[1]) for i in ls]
print(max(n_ls))

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

count = 0
for i in range(1, n):
    l = s[:i]
    r = s[i:]
    
    x = 0
    if len(set(l)) > len(set(r)):
        x = len(set(l)) - len(set(l) - set(r))
    else:
        x = len(set(r)) - len(set(r) - set(l))
    
    if count < x:
        count = x

print(count)

Solution (Python):
import sys

def input():
    return sys.stdin.readline().rstrip()

if __name__ == "__main__":
    n = int(input())
    s = input()

    ans = -float("inf")
    for i in range(1, n):
        l = set(s[:i])
        r = set(s[i:])
        ans = max(ans, len(l.intersection(r)))

    print(ans)

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

result = []

for i in range(N):
    a = set(list(S[:i]))
    b = set(list(S[i:]))
    result.append(len(a.intersection(b)))

print(max(result))

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

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

s = input()

ans = 0


for i in range(1, n):
    
    x = len(set(s[:i]).intersection(set(s[i:])))
    ans = max(ans, x)

print(ans)

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

def char_count(a, b):
    if len(a) < len(b):
        s1 = a
        s2 = b
    else:
        s1 = b
        s2 = a
    result = 0
    d = {}
    for s in s1:
        if s in d:
            continue
        d[s] = True
        if s in s2:
            result += 1
    return result

ans = 0
for i in range(1, N-1):
    ans = max(ans, char_count(S[:i], S[i:]))

print(ans)

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

print(res)

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

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


ans=[]

for i in range(n):
    a=set(s[:i])
    b=set(s[i:])
    ans.append(len(a&b))
print(max(ans))

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

Solution (Python):
n = int(input())
s = input()
list_ = []

for i in range(n):
    x = set(s[:i])
    y = set(s[i:])
    cnt = 0
    for j in x:
        if j in y:
            cnt += 1
    list_.append(cnt)

print(max(list_))

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

cnt = 0

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

print(cnt)

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

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

l=[]

for i in range(n-1):
    a = s[:i]
    b = s[i:]
    xy=set(a)&set(b)
    l.append(len(xy))
    

print(max(l))

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

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

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

Solution (Python):
n=int(input())
s=input()
count=0
x=[]
for i in range(n-1):
    a=s[:i+1]
    b=s[i+1:]
    for j in range(97,123):
        if a.count(chr(j))!=0 and b.count(chr(j))!=0:
            count+=1
    x.append(count)
    count=0
print(max(x))

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

count = 0

for i in range(1, N + 1):
    set_a = set(S[:i])
    set_b = set(S[i:])
    set_c = set_a & set_b
    count = max(count, len(set_c))
    
print(count)

Solution (Python):
n = int(input())
b = input()
ans = 0
for i in range(n):
    pre = 0
    temp = b[:i]
    for k in range(i, n):
        flag = True
        for dub in range(i, k):
            if b[dub] == b[k]:
                flag = False
                break
        if flag:
            for com in temp:
                if b[k] == com:
                    pre += 1
                    break
    if pre > ans:
        ans = pre
print(ans)

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

res = []
for i in range(N):
    former = set(S[:i])
    latter = set(S[i:])
    res.append(len(former & latter))
print(max(res))

Solution (Python):

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


if __name__ == "__main__":
    main()

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(set(X) & set(Y)))
print(count)

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

Solution (Python):
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N = n()
S = s()

max_common = 0
for i in range(1, N-1):
    X = set(S[:i])
    Y = set(S[i:])
    common = len(X.intersection(Y))
    if max_common < common:
        max_common = common
print(max_common)

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

maxcount=0
for i in range(n-1):
    left=s[:i+1]
    right=s[i+1:]
    
    leftset=set()
    for ss in left:
        leftset.add(ss)

    rightset=set()
    for ss in right:
        rightset.add(ss)

    maxcount=max(maxcount,len(leftset&rightset))
print(maxcount)

Solution (Python):
N = int(input())
S = list(input())
alphabet = 'abcdefghijklmnopqrstuvwxyz'
count = 0
ans = 0

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

print(ans)

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

al = [chr(i) for i in range(97, 97+26)]
ans = 0
for i in range(N):
    a = S[i:]
    b = S[:i]
    cnt = 0
    for j in al:
        if j in a and j in b:
            cnt+=1

    ans = max(ans, cnt)

print(ans)

Solution (Python):

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

ans = 0

for i in range(N):

    if i != 0:

        now = 0
        
        dicA = {}
        dicB = {}

        A = S[:i]
        B = S[i:]

        for j in A:
            dicA[j] = 1

        for j in B:
            dicB[j] = 1

        for j in dicA:

            if j in dicB:

                now += 1

        ans = max(ans,now)

print (ans)

Solution (Python):
n = int(input())
s = input().rstrip()
 
ans = 0
for i in range(1, len(s)):
  s1, s2 = s[0:i], s[i:]
  c = set(s1).intersection(set(s2))
  ans = max(ans, len(c))
print(ans)