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

resultMax = 0
for i in range(n):
  s1 = set(s[:i])
  s2 = set(s[i:])
  result = 0
  for j in s1:
    for k in s2:
      if j == k:
        result += 1
        break
  if resultMax < result:
    resultMax = result

print(resultMax)

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

print(ans)

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

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

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

print(ans)

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

f = ""
b = ""

L = [0] * N
con = 0

for i in range(N - 1):
  b = S[i + 1:]
  if S[i] in b and S[i] not in f:
    con += 1
    L[i] = con
  elif S[i] not in b and S[i] in f:
    con -= 1
    L[i] = con
  f += S[i]

  
print(max(L))

Solution (Python):
n=int(input())
s=input()
maxx=-1
def got(a,al):
    for i in a:
        if i==al :
      	    return(True)
    return(False)
for i in range(n):
    a=s[:i]
    b=s[i:]
    cnt=0
    alp="abcdefghijklmnopqrstuvwxyz"
    for al in alp:
        if got(a,al) and got(b,al):
      	    cnt+=1
    maxx=max(maxx,cnt)
print(maxx)

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

ans=0
for i in range(n-1):
  cnt=0
  a=set(s[:i+1])
  b=set(s[i+1:])
  for j in a:
    if j in b:
      cnt+=1
  if ans<cnt:
    ans=cnt

print(ans)

Solution (Python):
alp='abcdefghijklmnopqrstuvwxyz'
N=int(input())
S=input()
out=0
for i in range(1, N):
  X=S[:i]
  Y=S[i:]
  xs=[0]*26
  ys=[0]*26
  tmp=0
  for j in range(len(X)):
    xs[alp.index(X[j])]=1
  for j in range(len(Y)):
    ys[alp.index(Y[j])]=1
    
  for j in range(26):
    if xs[j]==1 and ys[j]==1:
      tmp+=1
      
  if out<tmp:
    out=tmp
print(out)

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

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

print(m)

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

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

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

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

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()
C = []

if S == S[0] * N:
  print(1)
else:
  for i in range(1, N):
    count = 0
    X = list(set(S[0:i]))
    Y = list(set(S[i:]))
    for j in range(len(X)):
      if Y.count(X[j]) > 0:
        count += 1
    C.append(count)

  print(max(C))

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

Solution (Python):
N = int(input())
S = input()
ans = 0
for i in range(1,N-1):
    lis1 = [0]*26
    lis2 = [0]*26
    for j,s in enumerate(S):
        if j<i:
            lis1[ord(s)-97] = 1
        else:
            lis2[ord(s)-97] = 1
    ans = max(ans,sum([lis1[i]*lis2[i] for i in range(26)]))
print(ans)

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

for i in range(1,n-1):
    
    mae = set(s[:i])
    ato = set(s[i:])
    cnt = mae & ato

    ans = max(ans,len(cnt))
    
print(ans)

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

Solution (Python):
import sys
import collections
from collections import Counter
input = sys.stdin.readline
N = int(input())
S = list(input())
count = -1000
del S[-1]
for i in range(N) :
    a = 0
    Sa = S[:i]
    Sb = S[i:]
    ca = collections.Counter(Sa)
    cb = collections.Counter(Sb)
    ka = list(ca.keys())
    kb = list(cb.keys())
    for j in ka :
        for k in kb :
            if j == k :
                a +=1
    count = max(a,count)
print(count)

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

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

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


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

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

res = []

for i in range(n):
    x = set(s[:i])
    y = set(s[i:])
    res.append(len(x & y))
print(max(res))

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

Solution (Python):

 
import math
import itertools
import sys
import copy
 



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

ans = 0
for i in range(1, N) :
  X = S[:i]
  Y = S[i:]
  
  
  Xlist = []
  Ylist = []
  cnt = 0
  for x in range(len(X)) :
    if X[x] not in Xlist :
      Xlist.append(X[x])
  for y in range(len(Y)) :
    if Y[y] not in Ylist :
      Ylist.append(Y[y])
  
  for xl in range(len(Xlist)) :
    if Xlist[xl] in Ylist :
      cnt += 1
  ans = max(ans, cnt)
  
print (ans)

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

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

Solution (Python):
def main():
    n = int(input())
    s = input()
    ma = 0
    for i in range(1, n):
        x = s[:i]
        y = s[i:]
        ma = max(ma, count_same(x, y))
    print(ma)


def count_same(x, y):
    return len(set(x) & set(y))


if __name__ == '__main__':
    main()

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

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

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

print(num)

Solution (Python):
n = int(input())
S = input()
ans = 0
for i in range(1, n):
    x = S[:i]
    y = S[i:]
    co = len(set(x) & set(y))
    if co > ans:
        ans = co

print(ans)

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

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

print(ans)

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


s= []
s.append(lst1.pop(0))
ans,res = 0,0
for i in range(n-1):
    res = 0
    for j in s:
        if j in lst1:
            res += 1
    if not lst1[0] in s:
        s.append(lst1.pop(0))
    else:
        del lst1[0]
    ans = max(ans,res)

print(ans)

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

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

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

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

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

Solution (Python):
import sys
input = sys.stdin.readline
N = int(input())
S = list(input())
ans = 0
for i in range(1, N-1):
    temp = []
    left = S[:i]
    right = S[i:]
    for i in left:
        if i in right and i not in temp:
            temp.append(i)
    ans = max(ans, len(temp))
print(ans)

Solution (Python):
import sys
from collections import Counter

n = int(sys.stdin.readline().rstrip())
s = sys.stdin.readline().rstrip()

def main():
    c = Counter(s)
    l = set()
    r = set(s)
    res = 0
    cnt = 0
    for letter in s:
        c[letter] -= 1
        if not c[letter]:
            r -= set([letter])
            if letter in l:
                cnt -= 1
        elif not letter in l:
            l.add(letter)
            cnt += 1
            res = max(res, cnt)
    return res

if __name__ == '__main__':
    ans = main()
    print(ans)

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

for i in range(n-1):
    x = list(s[:i+1])
    y = list(s[i+1:])
    x1 = list(set(x))
    y1 = list(set(y))
    z = x1 + y1
    z1 = list(set(z))

    lst.append(len(z)-len(z1))

print(max(lst))

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

ans = 0
for i in range(1, n):
    left = set(s[:i])
    right = set(s[i:])

    cnt = 0
    for l in left:
        if l in right:
            cnt += 1

    ans = max(ans, cnt)

print(ans)

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

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

print(ans)

Solution (Python):
n=int(input())
s=input()
ans=0
for i in range(1,n):
    A=s[:i]
    B=s[i:]
    asu=[]
    cnt=0
    for a in A:
        if a in B and a not in asu:
            cnt+=1
        asu.append(a)
    ans=max(ans,cnt)
print(ans)

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

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

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

def count(left, right):
  return len(set(left) & set(right))

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

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

Solution (Python):


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

lis_ans = []
for split in range(1,n):
    left = s[:split]
    right = s[split:]
    
    
    s_left = set(left)
    s_right = set(right)

    ans = 0
    for wl in s_left:
        for wr in s_right:
            if wl == wr:
                ans += 1

    lis_ans.append(ans)

print(max(lis_ans))

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

ans = []


for i in range (1,N):
    mae = S[:i]
    usiro = S[i:]
    mae_usiro = set(mae) & set(usiro)
    ans.append(len(mae_usiro))
    

print(max(ans))

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


if __name__ == "__main__":
    main()

Solution (Python):
n = input()
s = input()
ans = 0
tmp = 0
old = []
for i in range(1, len(s)):
    tmp = 0
    old = []
    for j in range(i):
        if s[j] in s[i:] and not(s[j] in old):
            tmp += 1
            old.append(s[j])
    ans = max(ans, tmp)
print(ans)

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

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

Solution (Python):
N = int(input())
S = input()
ans = 0
for i in range(N):
	cnt = 0
	type_flont= sorted(set(S[:i]),key=S.index)
	type_back= sorted(set(S[i:N]),key=S.index)
	for j in range(len(type_back)):
		if(type_back[j] in type_flont):
			cnt+=1
	if(ans < cnt):
		ans = cnt
print(ans)

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

ans = 0
for i in range(1, n):
    left = set(s[:i])
    right = set(s[i:])

    count = len(left & right)
    ans = max(ans, count)

print(ans)

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

ans = 0
for i in range(1, n):
    left = set(s[:i])
    right = set(s[i:])

    tmp = 0
    for j in left:
        if j in right:
            tmp += 1
    
    ans = max(ans, tmp)

print(ans)

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

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

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

Solution (Python):
n=int(input())
s=str(input())
ans=[]
li=["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"]  
for i in range(1,n):
    cnt=0
    for j in range(26):
        if li[j] in s[:i]:
            if li[j] in s[i:]:
                cnt+=1
    ans.append(cnt)   
print(max(ans))

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

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

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

ans = 0
for i in range(1, N):
    S1 = S[i:]
    S2 = S[:i]
    
    A = [0] * 26
    for j in range(len(S1)):
        t = ord(S1[j]) - 97
        A[t] += 1

    B = [0] * 26
    for j in range(len(S2)):
        t = ord(S2[j]) - 97
        B[t] += 1
    
    c = 0
    for k in range(26):
        if A[k] > 0 and B[k] > 0:
            c += 1

    ans = max(ans, c)

print(ans)

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

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

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

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

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

Solution (Python):
n=int(input())
s=input()
ls = list("abcdefghijklmnopqrstuvwxyz")
ans = [0]*n
for i in range(1,n):
  for j in ls:
    if j in s[:i] and j in s[i:]:
      ans[i]+=1
print(max(ans))

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

Solution (Python):
from collections import Counter
N = int(input())
S = input()
array = []
for i in range(1,N):
    S1 = list(S[:i])
    S2 = list(S[i:])
    S1c = Counter(S1)
    S2c = Counter(S2)
    suma = 0
    for k in S1c:
        if k in S2c:
            suma += 1
    array.append(suma)
print(max(array))

Solution (Python):
N=int(input())
S=[i for i in input()]


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

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

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

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

Solution (Python):
from __future__ import print_function


import sys
input = sys.stdin.readline

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd

def lcm(n,m):
    return int(n*m/gcd(n,m))

import re
import array
import copy
import functools
import operator

import collections
import itertools
import bisect
import heapq


from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace

from queue import PriorityQueue as pq

def reduce(p, q):
    common = fractions.gcd(p, q)
    return (p//common , q//common )



from operator import mul
from functools import reduce

def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

import random


def main():
    n = int(input().strip())
    s = input().strip()
    max_cnt=0
    for i in range(1,n):
        s1=set(s[0:i])
        s2=set(s[i:n])
        ss = s1 & s2
        cnt=len(ss)
        max_cnt=max(max_cnt,cnt)
    print(max_cnt)
    return

if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
s=input()
ans=0
for i in range(1,n):
    x=list(set(s[:i]))
    y=s[i:]
    tmp=0
    for xi in x:
        if xi in y:
            tmp+=1
    ans=max(ans,tmp)
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()
sset = set(s)
c = 0
for i in range(n):
    s1 = s[:i]
    s2 = s[i:]
    clst = [1 for i in sset if s1.count(i) > 0 and s2.count(i) > 0]
    tc = sum(clst)
    if tc > c:
        c = tc
print(c)

Solution (Python):

import sys


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


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())
x=[a for a in input()]
judge=list(set(x))
count=0
ans=[]


for j in range(N-1):
  for i in judge:
    X=x[0:j+1]
    Y=x[j+1::]
    if i in X and i in Y:
      count += 1
  else:
    ans.append(count)
    count=0
print(max(ans))

Solution (Python):

import collections
N = int(input())
S = str(input())
ans = 0
for i in range(1,N):
    Sa = S[0:i]
    Sb = S[i::]
    
    Sa_counted = collections.Counter(Sa)
    Sb_counted = collections.Counter(Sb)
    common_char = set(Sa_counted.keys()) & set(Sb_counted.keys())
    
    if len(common_char) > ans:
        ans = len(common_char)
        
print(ans)

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

ans = []
cnt = 0
for i in range(1,n):
    s1 = list(set(s[:i]))
    s2 = list(set(s[i:]))

    for j in range(len(s1)):
        for k in range(len(s2)):
            if s1[j] == s2[k]:
                cnt += 1
    ans.append(cnt)
    cnt = 0

print(max(ans))

Solution (Python):
alf = list(str('abcdefghijklmnopqrstuvwxyz'))
n = int(input())
s = str(input())
ans = 0
for i in range(len(s)):
    x = s[:i]
    y = s[i:]
    count = 0
    for j in alf:
        if j in x and j in y:
            count += 1
    if count > ans:
        ans = count
print(ans)

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

ans = 0

for i in range(n):
    cnt = 0
    x = s[:i]
    y = s[i:]
    for j in range(i):
        if x[j] in y and x[j] not in x[:j]:
            cnt += 1
    if cnt >= ans:
        ans = cnt

print(ans)

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

ans = 0

for i in range(len(s)-1):
	k = s[0:i+1]
	t = s[i+1:len(s)]
	
	maxstr = 0
	
	
	k = ''.join(set(k))
	
	for j in range(len(k)):
		if t.count(k[j]) != 0:
			
			maxstr = maxstr + 1
	if ans <= maxstr:
		ans = maxstr	

print(ans)

Solution (Python):
import collections

N = int(input())
S = input()
A = ''
B = S
ans = 0
for i in range(N):
  A += B[0]
  B = B[1:]
  C = collections.Counter(A)
  D = 0
  for w in C:
    if w in B:
      D += 1
  if D > ans:
    ans = D
print(ans)

Solution (Python):
N=int(input())
S=list(input())
X=[]
Y=[]
cnt=[]
for i in range(N-1):
    X=S[0:i+1]
    Y=S[i+1:N]
    cnt.append(len(set(X) & set(Y)))

print(max(cnt))

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

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

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

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

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

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

for i in range(1,N):
	valiation=0
	A=sorted(S[:i])
	B=sorted(S[i:])
	for j in range(i):
		if (j==0 or A[j]!=A[j-1]) and A[j] in B:
			valiation+=1
	result=max(result,valiation)
print(result)

Solution (Python):
from collections import Counter
n = int(input())
s = input()
ans = 0
for i in range(1,n):
    c1 = Counter(s[:i])
    c2 = Counter(s[-(n-i):])
    cnt = 0
    for c in c1:
        if c2[c] > 0:
            cnt += 1
    ans = max(ans,cnt)
print(ans)

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

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

Solution (Python):
n = int(input())
s = str(input())
S = []
for t in s:
    S.append(t)

ans = 0
for i in range(n):
    left = S[:i]
    right = S[i:]
    count = len(set(left) & set(right))
    if count >= ans:
        ans = count

print(ans)

Solution (Python):


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

for sp in range(1,N):
    l=S[:sp]
    r=S[sp:]

    maxd=max(maxd,len(list(set(l)&set(r))))

print(maxd)

Solution (Python):
N = int(input())
S = list(map(str,input()))
target = len(set(S))
count = list()
for i in range(1,N):
	X = set(S[:i])
	Y = set(S[i:])
	
	symmetric_difference = X ^ Y
	count.append(target - len(symmetric_difference))
	
	
print(max(count))

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):
def examB():
    N = I()
    S = SI()
    cur = 0
    for i in range(N-1):
        d1 = set()
        d2 = set()
        for j in S[:i]:
            d1.add(j)
        for j in S[i:]:
            d2.add(j)
        curS = d1&d2
        cur = max(cur,len(curS))
    print(cur)


import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()

Solution (Python):
A = int(input())
B = input()
m = 0
for i in range(A):
  c = set(B[:i])
  a = set(B[i:])
  l = a & c
  m = max(m,len(l))
print(m)

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

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

Solution (Python):

import sys, math, itertools, heapq, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans = count = 0

n=int(input())
s=input()
for i in range(1,n):
    A=set(s[:i])
    B=set(s[i:])
    for ai in A:
        if ai in B:
            count+=1
    ans=max(ans,count)
    count=0
print(ans)

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

ans = 0
for i in range(1, n):
    s1, s2 = s[:i], s[i:]
    cnt = len(set(s1) & set(s2))
    if ans < cnt:
        ans = cnt

print(ans)

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

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

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

Solution (Python):
def f(s, t):
    return len(set(s) & set(t))

N = int(input())
S = input()
ans = 0
for i in range(N):
    ans = max(ans, f(S[:i], S[i:]))
print(ans)

Solution (Python):
def f(s, t):
    res = 0
    for i in set(s):
        for j in set(t):
            if i == j:
                res += 1
    return res

N = int(input())
S = input()
ans = 0
for i in range(N):
    ans = max(ans, f(S[:i], S[i:]))
print(ans)

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

x=[0]*n
for c in "abcdefghijklmnopqrstuvwxyz":
  b,e=s.find(c),s.rfind(c)
  if b!=e:
    for i in range(b,e+1):
      x[i]+=1

print(max(x))

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

Solution (Python):
n = int(input())
s = input()
max_num = 0
for i in range(1, n):
  s_1 = s[:i]
  s_2 = s[i:]
  temp = len(set(s_1) & set(s_2))
  if temp > max_num:
    max_num = temp
print(max_num)

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

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

print(ans)

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

Solution (Python):


def main():
    N = int(input())
    S = input()
    max_score = 0
    for i in range(N):
        left = "".join(set(S[:i]))
        right = "".join(set(S[i:]))
        score = 0
        for i in range(len(left)):
            if left[i] in right:
                score += 1
        max_score = max(max_score,score)
    print(max_score)

if __name__ == "__main__":
    main()

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

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

ans = 0
for i in range(1,n-1):
    a = Counter(s[:i])
    b = Counter(s[i:])
    cnt = 0
    for k in a.keys():
        if k in b:
            cnt += 1
    if cnt > ans:
        ans = cnt
print(ans)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

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

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):
N = int(input())
S = input()
ans = 0
for i in range(1,len(S)):
    X = S[:i]
    Y = S[i:]
    dic = {}
    for j in X:
        if( (j in Y) == True):
            dic[j] = 0
        ans = max(ans,len(dic))
print(ans)

Solution (Python):
from sys import stdin

n = int(stdin.readline().rstrip())
s = stdin.readline().rstrip()
s = [str(i) for i in s]

ma = 0
for i in range(len(s)):
    point = 0
    fi = list(set(s[:i]))
    la = list(set(s[i:]))
    for j in fi:
        if j in la:
            point += 1
    ma =  max(ma,point)

print(ma)

Solution (Python):
N = int(input())
S = input()
k = len(set(S))

count = 0
for i in range(1, N-k+1):
    X = set(S[:i])
    Y = set(S[i:])
    c = sum([1 if x in Y else 0 for x in X])
    count = c if c > count else count

print(count)

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

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

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

set_s = set(s)
the_number = 0

for i in range(1, n):
    the_number_of_this_cut = 0

    x = set(list(s[:i]))
    y = set(list(s[i:]))

    for letter in set_s:
        if letter in x and letter in y:
            the_number_of_this_cut += 1
    
    the_number = max(the_number, the_number_of_this_cut)

print(the_number)

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

ans = 0
for i in range(N):
    left = []
    right = []
    for j in range(N):
        if j <= i:
            if S[j] not in left:
                left.append(S[j])
        else:
            if S[j] not in right:
                right.append(S[j])
    tmp_ans = 0
    for j in range(len(left)):
        if left[j] in right:
            tmp_ans += 1
    ans = max(ans, tmp_ans)
    
print(ans)

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

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

value=0
ord("a")
for i in range(1,N):
    data1=[0 for i in range(ord("z")-ord("a")+1)]
    data2=[0 for i in range(ord("z")-ord("a")+1)]
    for s in S[:i]:
        data1[ord(s)-ord("a")]+=1
    for s in S[i:]:
        data2[ord(s)-ord("a")]+=1

    value=max(len([1 for i,m in zip(data1,data2) if i and m]),value)
print(value)

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

for i in range(n-1):
  temp = len(set(list(S[0:i+1]))&set(list(S[i+1:n])))
  if temp > counter:
    counter = temp

print(counter)