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

ans = 0
for i in range(N+1):
  left = set(S[:i])
  right = set(S[i:])

  tmp = 0
  for j in left:
    if j in right:
      tmp += 1

  if ans<tmp:
    ans = tmp

print(ans)

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

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

  k=0
  for j in range(ord('a'),ord('z')+1):
    if left.count(chr(j))>0 and right.count(chr(j))>0:
      k += 1

  if ans<k:
    ans = k

print(ans)

Solution (Python):
n = int(input())
s = input()
ans = 0
 
for i in range(n):
    a = s[:i]
    b = s[i:]
    tes = 0
    c = []
    for cha in a:
        if cha in b:
            if cha not in c:
                c.append(cha)
                tes += 1
    ans = max(tes,ans)

    
print(ans)

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

ans=0
for i in range(n):
    cnt=0
    d={}
    for si in s[:i]:
        if si in s[i:] and si not in d:
            cnt+=1
            d[si]=True
    ans=max(ans, cnt)    
print(ans)

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

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

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

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

ans = 0
for i in range(n):
  left, right = s[:i], s[i:]
  cnt = len(set(left) & set(right))
  ans = max(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:])
    ans = max(ans,len(left&right))

print(ans)

Solution (Python):
N=int(input())
s=input()
res=0
for i in range(1,N):
    X=s[:i]
    Y=s[i:]
    n=0
    for j in range(97,123):
        if X.count(chr(j))!=0 and Y.count(chr(j))!=0:
            n+=1
    res=max(res,n)
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()

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

max_n = 0

for i in range(1,n):
    x = set()
    y = set()
    for j in range(0,i):
        x.add(s[j])
    for j in range(i,n):
        y.add(s[j])

    if len(x&y) > max_n:
        max_n = len(x&y)

print(max_n)

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

x_max = 0

for i in range(1,N):
    A = set(S[0:i])
    B = set(S[i:])
    
    x = len(A&B)
    
    if x_max < x:
        x_max = x
        
print(x_max)

Solution (Python):
from collections import Counter

n = int(input()) 
S = input()



count = [0 for x in range(n)]

for i in range(n):
    S1 = S[0:i]
    S1c = Counter(S1)
    
    

    S2 = S[i:n]
    S2c = Counter(S2)
    

    for alphabet in S1c.keys():
        if alphabet in S2c.keys():
            count[i] += 1


print(max(count))

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

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

Solution (Python):

"""
B - Cut and Count

"""
import sys
from sys import stdin
input = stdin.readline


def solve(N, S):
    ans = 0
    for n in range(N):
        left = set(S[:n])
        right = set(S[n:])
        ans = max(ans, len(left & right))
    return ans


def main(args):
    N = int(input())
    S = input().strip()
    ans = solve(N, S)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

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

Solution (Python):
n = int(input())
s = input()
n1 = []
for i in range(n):
    s1 = set()
    for j in range(i+1):
        for k in range(i+1, n):
            
            if s[j] == s[k] and set(s[j]).issubset(s1) is False:
                s1.add(s[j])
            
    n1.append(len(s1))
print(max(n1))

Solution (Python):

from string import ascii_lowercase
from collections import Counter
def inpl(): return map(int, input().split())

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

ans = 0

for i in range(N):
    tmp = 0
    A = Counter(S[:i])
    B = Counter(S[i:])
    for a in ascii_lowercase:
        tmp += (A[a] > 0)&(B[a] > 0)
    ans = max(ans, tmp)

print(ans)

Solution (Python):
N = int(input())
S = input()
ans = 0
alphabets = ['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(N + 1):
    former = S[:i + 1]
    latter = S[i + 1:]
    count = 0
    for j in alphabets:
        if (j in former) and (j in latter):
            count += 1
    if count > ans:
        ans = count
print(ans)

Solution (Python):
n = int(input())
s = input()
split_chars = ((set(s[:i]), set(s[i:])) for i in range(1, n))
common_chars = (set.intersection(*charsets) for charsets in split_chars)
print(max(len(chars) for chars in common_chars))

Solution (Python):
n = int(input())
word = input().strip()

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

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

maxlen = 0

for i in range(N):
	a = S[0:i+1]
	b = S[i+1:N]
	aset = set(a)
	bset = set(b)

	ans = aset & bset

	if len(ans) >= maxlen:
		maxlen = len(ans)

print(maxlen)

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

ans = -1
for i in range(n-1):
    temp = 0
    s_1st = list(set(s[0:i+1]))
    s_2nd = list(set(s[i+1:n+1]))
    for j in range(len(s_1st)):
        if s_1st[j] in s_2nd:
            temp += 1
    if ans <= temp:
        ans = temp
        
print(ans)

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

Solution (Python):


n = int(input().rstrip())

line = input().rstrip()

max_count = 0
for i in range(n):
    a = set(line[0:i])
    b = set(line[i:])
    count = len(a.intersection(b))
    if max_count < count:
        max_count = count

print(max_count)

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

max_num=0
for i in range(N):
	X=S[:i:]
	Y=S[i::]
	num=0
	for char in [chr(i) for i in range(97,97+26)]:
		if (char in X) and (char in Y):
			num=num+1
	if max_num<num:
		max_num=num
print(max_num)

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

S = list(S)
res = 0
for i in range(1, N):
    S1 = set(S[:i])
    S2 = set(S[i:])
    if(len(S1.intersection(S2)) > res):
        res = len(S1.intersection(S2))

print(res)

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

for i in range(n+1):
	f = set(s[i:])
	b = set(s[:i])
	count = len(f & b)
	if c < count:
		c = count
print(c)

Solution (Python):
N=int(input())
s=input()
count=[]
for i in range (N):
    count.append(0)
    for k in range (i):
        if(s[k] in s[i:]):
            count[i]=count[i]+1
            if(s[k] in s[:k]):
                count[i]=count[i]-1
print(max(count))

Solution (Python):
N=int(input())
S=input()
S_list=list(S)
S_max=0
for n in range(N):
    S_list_former=set(S_list[:n])
    S_list_latter=set(S_list[n:N])
    S_list_com=len(S_list_former & S_list_latter)
    if S_list_com>=S_max:
        S_max=S_list_com
print(S_max)

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

Solution (Python):
n = int(input())
s = input()
x = 0
for i in range(n+1):
    f = set(s[i:])
    d = set(s[:i])
    count =len(f & d)
    if count > x:
        x = count
print(x)

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

ans = 0

for i in range(N):
    s1 = S[0 : i+1]
    s2 = S[i+1 : N]
    set1 = set(s1)
    set2 = set(s2)
    if ans <= len(set1 & set2):
        ans = len(set1 & set2)

print(ans)

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

ans = 0

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

print(ans)

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

Solution (Python):
n = int(input())
s = input()
c = 0
for i in range(n+1):
    f = set(s[i:])
    d = set(s[:i])
    count =len(f & d)
    if count > c:
        c = count
print(c)

Solution (Python):

num = int(input())
li = list(input())
ans = 0
for i in range(num):
    fi = set(li[:i])
    se = set(li[i:])
    hoge = len(list(fi & se))
    if hoge > ans:
        ans = hoge
    
print(ans)

Solution (Python):
N=int(input().strip())
S=input().strip()
maxnum=0
for i in range(1,N):
    if min(i, N-i) < maxnum:
        continue
    s1=set(i for i in S[:i])
    s2=set(i for i in S[i:])
    num=0
    for c in s1:
        if c in s2:
            num+=1
    if num > maxnum:
        maxnum=num
print(maxnum)

Solution (Python):
num = int(input())
li = list(input())
ans = 0
for i in range(num):
  fi = set(li[:i])
  se = set(li[i:])
  hoge = len(list(fi & se))
  if hoge > ans:
    ans = hoge
 
print(ans)

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

for i in range(n-1):
    s1 = s[0:i+1]
    s2 = s[i+1:n]
    res_1 = 0
    for alp in range(ord('a'),ord('z')+1):
        if s1.find(chr(alp)) > -1:
            if s2.find(chr(alp)) > -1:
                res_1 = res_1 + 1
    if res < res_1:
        res = res_1

print(res)

Solution (Python):



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

ans = 0

for i in range(1,N):
	curr = 0
	s = S[:i]
	r = S[i:]
	for j in range(97,123):
		char = chr(j)
		if(char in s and char in r):
			curr += 1
	ans = max(ans, curr)

print(ans)

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

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

Solution (Python):
n = int(input())
s = input()
k = 0
for n in range(1,n):
    a =  set(s[:n]) & set(s[n:])
    if len(a) > k :
        k = len(a)
print('{}'.format(k))

Solution (Python):
n, s = [input() for i in range(2)]
n = int(n)

list(s)

count = 0
for i in range(1, n):
    x, y = set(s[:i]), set(s[i:])
    count = len(x & y) if count < len(x & y) else count

print(count)

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

max_c = 0
for i in range(1, N):
    x, y = S[:i], S[i:]
    max_c = max(len(set(x) & set(y)), max_c)
print(max_c)

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

print(x)

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

maxx=0
for i in range(1,n):
    l={}
    r={}
    for j in range(i):
        if S[j] in l:
            l[S[j]]+=1
        else:
            l[S[j]]=1
    for j in range(i,n):
        if S[j] in r:
            r[S[j]]+=1
        else:
            r[S[j]]=1
    count=0
    for c in l:
        if c in r:
            count+=1
    maxx=max(maxx,count)

print(maxx)

Solution (Python):
from collections import Counter

n = int(input())
s = input()
cnt_l = []
for i in range(n - 1):
  str1_cnt = Counter(s[:i + 1])
  str2_cnt = Counter(s[i + 1:])
  cnt_l.append(len(set(list(str1_cnt)) & set(list(str2_cnt))))
print(max(cnt_l))

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

x = 0

for i in range(len(s)):
  a = s[0:i]
  b = s[i:]
  
  x = max(x, len(set(a) & set(b)))

print(x)

Solution (Python):


''' "効率の良い" アルゴリズム

各文字について「最初の出現と最後の出現の間の切断位置」に1を、
そのほかに0を割り当てる:
(s) a b r a c a d a b r a
a: 0 1 1 1 1 1 1 1 1 1 1 0
b: 0 0 1 1 1 1 1 1 1 0 0 0
c: 0 0 0 0 0 0 0 0 0 0 0 0
d: 0 0 0 0 0 0 0 0 0 0 0 0
r: 0 0 0 1 1 1 1 1 1 1 0 0

合計を計算する:
+: 0 1 2 3 3 3 3 3 3 2 1 0

最大をとる:
3

ただし、2次元の表を作るのはまだ効率が悪いので、実際には次のようにする。
各位置について「その位置の文字が最初であって最後でないなら+1,
最後であって最初でないなら-1, さもなければ0」を割り当てる:

(s) a b r a c a d a b r a
    + + +           - - -
これは前後から「もう見た文字」以外をたどればよい。

手前から順に足していき、最大をとる:
max(1,2,3,3,3,3,3,3,2,1,0)
'''
n = int(input())
s = input()
point = [0 for _ in range(n)]

seen_forward = set()
for i, letter in enumerate(s):
    if letter not in seen_forward:
        point[i] += 1
        seen_forward.add(letter)

seen_backward = set()
for i, letter in reversed(list(enumerate(s))):
    if letter not in seen_backward:
        point[i] -= 1
        seen_backward.add(letter)

current_score, max_score = 0, 0
for p in point:
    current_score += p
    max_score = max(max_score, current_score)

print(max_score)

Solution (Python):
n = int(input())
s = input()
alphabets = 'abcdefghijklmnopqrstuvwxyz'
scores = []
for i in range(n):
    count = 0
    for alphabet in alphabets:
        if alphabet in s[:i] and alphabet in s[i:]:
            count += 1
    scores.append(count)
print(max(scores))

Solution (Python):
N = int(input())
S = list(input())
alp = ["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"]
X = []
Y = S
max=[]
for i in range(N):
    X.append(Y[0])
    del Y[0]
    count = 0
    for j in range(26):
        if X.count(alp[j]) > 0 and Y.count(alp[j]):
            count += 1
        max.append(count)
max.sort(reverse = True)
print(max[0])

Solution (Python):
N = int(input())
S = input()
temp=0
for i in range(N-1):
    S1=S[0:i+1]
    S2=S[i+1:N]

    kaburi=[]
    for s in S1:
        if s in S2 and s not in kaburi:
            kaburi.append(s)
    if len(kaburi)>temp:
        temp = len(kaburi)
print(temp)

Solution (Python):
n=int(input())
s=input()
ss=[i for i in s]
w=0
for i in range(1,n):
    
    a=set(ss[:i])
    b=set(ss[i:])

    v=0
    for aa in a:
        
        
        if aa in b:
            v+=1
            
            
            
            
            
        
    if v>w:
        w=v
print(w)

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

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

max = 0
count = 0
check = []

for i in range(1,N):
  count = 0
  check = []
  left = S[:i]
  right = S[i:]
  for j in left:
    if j in right and j not in check:
      count += 1
    check.append(j)
  if count >= max:
    max = count
    
print(max)

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

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

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

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

Solution (Python):
N = int(input())
S = input()
ans = 0
for i in range(N):
    x,y = S[0:i+1], S[i+1:]
    tmp = 0
    al = []
    for xi in x:
        if xi in y and not xi in al:
            al.append(xi)
            tmp += 1
    ans = max(ans,tmp)
print(ans)

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

letters = []
for i in range(N):
    if S[i] not in letters:
        letters.append(S[i])

ans = 0
for i in range(N):
    kinds = 0
    left = S[:i]
    right = S[i:]
    for j in range(len(letters)):
        if((letters[j] in left) and (letters[j] in right)):
            kinds = kinds + 1
    ans = max(kinds,ans)

print(ans)

Solution (Python):
def cut_count(N, S):
    counter = [0]
    for i in range(1, N):
        x = list(set(S[:i]))
        y = ''.join(list(set(S[i:])))
        c = [y.count(x[j]) for j in range(len(x))]
        if sum(c) != 0:
            counter.append(sum(c))
        else:
            pass
    return max(counter)

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

if __name__ == "__main__":
    main()

Solution (Python):
import string

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

count = 0
for i in range(n - 1):
  count1 = 0
  for j in string.ascii_lowercase:
    x = s[:i+1]
    y = s[i+1:]
    if j in x and j in y:
      count1 += 1
  if count1 > count:
    count = count1
print(count)

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

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

Solution (Python):
N = int(raw_input())
S = str(raw_input())
opt_num = 0
dict = {}
dict2 = {}
for i in range(N-1):
    first = S[:i+1]
    latter = S[i+1:]
    for l in S:
        dict[l] = 0
    dict2 = {}
    cnt = 0
    for f in first:
        dict[f] = 1
    for l in latter:
        if dict[l]:
            dict2[l] = 1
    if opt_num < len(dict2):
        opt_num = len(dict2)
print(opt_num)

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

ans = 0

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

Solution (Python):
def getinputdata():

    
    array_result = []    
    data = input()
    array_result.append(data.split(" "))

    flg = True

    try:
        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = True

            else:

                flg = False
    finally:

        return array_result

arr_data = getinputdata()

n = int(arr_data[0][0])
s = arr_data[1][0]

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

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

posDevide = 1
maxMatchWordNum = 0

while posDevide <=  N - 1:
        arrayNum = 0
        matchWordNum = 0
        while arrayNum < posDevide:
                if arrayNum  == S.find( S[ arrayNum ], 0, posDevide):
                        matchWordNum = matchWordNum + 1 if  bool( S.count( S[ arrayNum ], posDevide, N )) else matchWordNum

                arrayNum += 1

        maxMatchWordNum = matchWordNum if matchWordNum > maxMatchWordNum else maxMatchWordNum
        posDevide += 1

print(maxMatchWordNum)

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

former = set(s[0])
latter = set(s[1:])
ans = len(former & latter)

for i in range(2, n):
	former = set(s[:i])
	latter = set(s[i:])
	if len(former & latter) > ans:
		ans = len(former & latter)
        
print(ans)

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

Solution (Python):
n=int(input())
s=input()
import collections
t=[]
for i in range(1,n):
    x=s[:i]
    y=s[i:]
    c = collections.Counter(x)
    d = collections.Counter(y)
    t.append(len(set(c)&set(d)))
print(max(t))

Solution (Python):
from sys import stdin


def main():
    N = int(stdin.readline().rstrip())
    S = stdin.readline().rstrip()
    print(max([len(set(S[:i]) & set(S[i:])) for i in range(1, N)]))


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
s = input()
ret = 0
for i in range(len(s)):
    sa = s[:i]
    sb = s[i:]
    bot = [0]*26
    for j in range(26):
        c = chr(j+ord('a'))
        if c in sa and c in sb:
            bot[j] += 1
    ret = max(ret,sum(bot))
print(ret)

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

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()
list=list(S)
x=0
for j in range(N+1):
    a=0
    for i in range(97,123):

        if (chr(i) in list[0:j]) and (chr(i) in list[j:N]):
            a+=1
    if a>x:
        x=a
print(x)

Solution (Python):
n=int(input())
m=list(input())
ans=0
for i in range(n-1):
    p=0
    x=list(set(m[:i+1]))
    y=list(set(m[i+1:]))
    for j in x:
        if j in y:
            p+=1
    ans=max(ans,p)
print(ans)

Solution (Python):
a=int(input())
b=input()
d=0

for i in range(a):
 c=0
 data=b[0:i]
 match=b[i:a]
 data_uniq=list(set(data))
 match_uniq=list(set(match))
 for x in range(len(data_uniq)):
  for y in range(len(match_uniq)):
   if data_uniq[x]==match_uniq[y]: 
    c+=1
    d=max(d,c)
                   

print (d)

Solution (Python):
def main():
    N = int(input())
    S = input()
    max = 0;
    for i in range(1, N):
        l = S[:i]
        r = S[i:]
        used = []
        for k in l:
            if k in r and k not in used:
                used.append(k)
        if len(used) > max: max = len(used)
    print(max)

if __name__ == '__main__':
  main()

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

max = -1

for i in range(1,n):
	syu = []
	x = s[0:i]
	y = s[i:]
	
	for moji in x:
		if moji not in syu and moji in y:
			syu.append(moji)
	
	if max < len(syu):
		max = len(syu)
	
print(max)

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

max_common = -1

for i in range(1,n):
    common = []
    x = s[0:i]
    y = s[i:]
    
    
    for letter in x:
        if letter not in common and letter in y:
            common.append(letter)
    
    
    max_common = max(len(common), max_common)
    
    
print(max_common)

Solution (Python):

raw_input()
str = raw_input()
nums = []
for i in range(1,len(str)):
    count = 0
    chars = []
    
    for c in str[0:i]:
        if not c in chars and c in str[i:len(str)]:
            chars.append(c)
            count +=1
    nums.append(count)
print max(nums)

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

ans = list()

for i in range(len(s)):
    cnt = 0
    x = sorted(set(s[:i]), key=s.index)
    y = sorted(set(s[i:]), key=s.index)
    for j in x:
        if j in y:
            cnt += 1
    ans.append(cnt)

print(max(ans))

Solution (Python):


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

alphabets = "abcdefghijklmnopqrstuvwxyz"

res = 0

for i in range(1, n):

    matches = 0

    s1 = s[:i]
    s2 = s[i:]

    for c in list(alphabets):
        if s1.find(c) != -1 and s2.find(c) != -1:
            matches += 1

    if matches > res: res = matches

print(res)

Solution (Python):


def main():
    N = int(input())
    S = input()
    q = set(S)
    ans = 0
    for i in range(1, N):
        a = set(S[:i])
        b = set(S[i:])
        cnt = 0
        for j in q:
            if j in a and j in b : cnt += 1
        ans = max(cnt, ans)
    print(ans)
main()

Solution (Python):



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

max = 0
for i in range(1, len(s)):
    left = s[:i]
    right = s[i:]
    buf = []
    for j in left:
        if j in right and j not in buf:
            buf.append(j)
    if max < len(buf):
        max = len(buf)
print(max)

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

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

ans = 0
for i in range(N):
    X, Y = set(), set()
    for j in range(N):
        if j < i:
            X.add(S[j])
        else:
            Y.add(S[j])

    same = len(X & Y)
    if same > ans:
        ans = same
print(ans)

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

count = 0
for i in range(N + 1):
    x_chars = set(list(S[:i]))
    y_chars = set(list(S[i:]))
    both = x_chars & y_chars
    if len(both) > count:
        count = len(both)

print(count)

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

max_diff = 0
for i in range(1, len(s)):
  s1 = s[:i]
  s2 = s[i:]
  diff = len(set(s1) & set(s2))
  if diff > max_diff:
    max_diff = diff
print(max_diff)

Solution (Python):
n=int(input())
s=str(input())
ans=0
for i in range(n):
    k=0
    arr=[]
    for j in range(i+1):
        if(s[j] in s[i+1:] and s[j] not in arr):
            k+=1
            arr.append(s[j])
    if(k>ans):
        ans=k
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()

same_num = -1

for i in range(N):
    s1 = set(S[:i+1])
    s2 = set(S[i+1:])
    if len(s1 & s2) > same_num:
        same_num = len(s1 & s2)

print(same_num)

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

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

print(ans)

Solution (Python):
N = int(input())
S = input()
lcnt=[]

def div(x):
    s1,s2="",""
    for i in range(x):
        s1+=S[i]
    for i in range(N-x):
        s2+=S[x+i]
    return s1,s2

def count(s1,s2):
    cnt=0
    s1=list(set(s1))
    for i in range(len(s1)):
        if s1[i] in s2:
            cnt+=1
    return cnt

for i in range(1,N):
    s1,s2=div(i)
    cnt=count(s1,s2)
    lcnt.append(cnt)
    
print(max(lcnt))

Solution (Python):
n = int(input())
s = input()
max_sep = 0
for i in range(n):
  s1 = s[:i]
  set1 = set(list(s1))
  s2 = s[i:]
  set2 = set(list(s2))
  set_all = set1 & set2
  max_sep = max(max_sep, len(set_all))

print(max_sep)

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

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

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

print(ans)

Solution (Python):
N = int(input())
S = input()
maxn =0
alp = [chr(i) for i in range(97, 97+26)]
for i in range(N-1):
  A = S[:i+1:]
  B = S[i+1::]
  count = 0
  for j in alp:
    if A.find(j)!=-1 and B.find(j)!=-1:
      count+=1
  maxn = max(maxn,count)
print(maxn)

Solution (Python):
N = int(input())
S = input()
ans = 0
for k in range(N):
    t = 0
    T = set([x for x in S[:k]])
    U = set([x for x in S[k:]])
    for x in T:
        if x in U:
            t += 1
    ans = max(ans,t)

print(ans)

Solution (Python):
N = int(input())
S = list(input())
ans = 0
for i in range(N):
  Sp = list(set(S[0 : i + 1]))
  Ss = list(set(S[i + 1 : N]))
  temp = 0
  for x in Sp:
    for y in Ss:
      if x == y:
        temp += 1
        break
  if temp > ans:
    ans = temp
print(ans)

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

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


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

print(result)

Solution (Python):

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


def calcCountUnion(X, Y):
    counter = 0
    for key in X.keys():
        if key in Y.keys():
            counter += 1
    return counter


def str2dict(S):
    X = {}
    Y = {}
    for a in S:
        X[a] = X[a] + 1 if (a in X.keys()) else 1
    return X, Y


def calcMaxCutCount(S):
    X, Y = str2dict(S)
    maxCutCount = 0
    for a in S:
        X[a] = X[a] - 1
        Y[a] = X[a] + 1 if (a in X.keys()) else 1
        if X[a] <= 0:
            X.pop(a)
        tmp = calcCountUnion(X, Y)
        maxCutCount = max((tmp, maxCutCount))
    return maxCutCount


print(calcMaxCutCount(S))

Solution (Python):
def alphabet_str(string):
    n = len(string)
    dict = ""
    for c in string:
        if dict.find(c) == -1:
            dict += c
    
    return dict


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

str = list(S)
str1 = ""
str2 = S

max = 0

for i in range(0,N-1):
    sum = 0
    str1 += str[i]
    str2 = str2[1:]
    dict1 = alphabet_str(str1)
    dict2 = alphabet_str(str2)
   
    for c in dict1:
        if dict2.find(c) >= 0:
            sum += 1
   
    if sum > max:
        max = sum
print(max)

Solution (Python):
def max_common(n, s):
    maximum = 0
    for i in range(1, n):
        set_left = set(s[:i])
        set_right = set(s[i:])
        maximum = max(maximum, len(set_left.intersection(set_right)))
    return maximum


if __name__ == '__main__':
    n = int(input())
    s = input()
    print(max_common(n, s))

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

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

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

Solution (Python):
if __name__ == '__main__':
    a = int(input())
    b = input()

    counts = []
    for i in range(1, a):
        count = 0
        b_1 = b[0:i]
        b_1 = list(set(list(b_1)))
        b_2 = b[i:a]
        b_2 = list(set(list(b_2)))
        for x in range(0, len(b_1)):
            for y in range(0, len(b_2)):
                if b_1[x] == b_2[y]:
                    count = count + 1

            counts.append(count)

    print(max(counts))

Solution (Python):
n = int(input())
s = list(input())
dp = [0 for i in range(n+1)]

for i in range(n):
    if (s[i] in s[i+1:]) and (s[i] not in s[:i]):
        dp[i+1] = dp[i]+1
    elif (s[i] not in s[i+1:]) and (s[i] in s[:i]):
        dp[i+1] = dp[i]-1
    else:
        dp[i+1] = dp[i]

print(max(dp))

Solution (Python):
import string

N = int(input())
S = input()
ret = 0
for i in range(1, N):
    k = 0
    for s in string.ascii_lowercase:
        if s in S[:i] and s in S[i:]:
            k += 1
    ret = max(ret, k)
print(ret)

Solution (Python):
n=int(input())
s=input()
m=i=d=n//2
a=0
for _ in range(m):
    left=set(s[:i])
    right=set(s[i:])
    b=len(left&right)
    if a<b:
        a=b
    left=set(s[:d])
    right=set(s[d:])
    b=len(left&right)
    if a<b:
        a=b
    i=i+1
    d=d-1
print(a)

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

Solution (Python):
from sys import stdin

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


max = 0

N = int(N)

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


print(max)

Solution (Python):
if __name__ == '__main__':
    n = int(input())
    s = input()

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

    print(a)