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()
max = 0
for i in range(n-1):
    be = s[:i+1]
    af = s[i+1:n]
    c = []
    d = []
    count = 0
    for j in range(len(be)):
        if not be[j] in c:
            c.append(be[j])
    for k in range(len(af)):
        if not af[k] in d:
            d.append(af[k])
    for l in c:
        if l in d:
            count += 1
    if count > max:
        max = count

print(max)

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 = input()
maxd = 0
for a in range(1,N-1):
    X = set([])
    Y = set([])
    for x in range(0,a):
        X.add(S[x])
    for y in range(a,N):
        Y.add(S[y])
    diffnum = len(X&Y)
    maxd = max(diffnum,maxd)
print(maxd)

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

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

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


def cal(n):
    result = 0
    former = set()
    latter = set()
    for i in range(N):
        if i <= n:
            former.add(S[i])
        else:
            latter.add(S[i])
    union = former & latter
    if result < len(union):
        result = len(union)
    return result

for i in range(N):
    a.append(cal(i))
print(max(a))

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

cnt_MAX = 0
for i,s in enumerate(S):
    X = S[:i]
    Y = S[i:]
    cnt = 0
    for x in set(list(X)):
        if x in Y:
            cnt += 1
    if cnt > cnt_MAX:
        cnt_MAX = cnt
print(cnt_MAX)

Solution (Python):


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

nummax = 0
for i in range(1, len(s)):
    s1 = s[0:i]
    s2 = s[i:]
    s1s = set()
    for j in s1:
        s1s.add(j)
    num = 0
    for j in s1s:
        if s2.count(j):
            num += 1
    nummax = max(nummax, num)

print(nummax)

Solution (Python):
n = int(input())
s = list(input())
o_s = list(set(s))
counter = 0
max = 0
for i in range(1,n):
    left = set(s[0:i])
    right = set(s[i:n])
    for j in left:
        if(j in right):
            counter += 1
    if max < counter :
        max = counter
    counter = 0
print(max)

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

max = 0
for i in range(N):
 cnt = 0
 common = []
 X = S[0:i]
 Y = S[i:N]
 for k in X:
  if k in Y and k not in common:
   common.append(k)
   cnt += 1
 if cnt > max:
  max = cnt

print(max)

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

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

num_type_max = 0

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

    num_type = 0
    for s in s1:
        if s in s2:
            num_type += 1
    if num_type > num_type_max:
        num_type_max = num_type

print(num_type_max)

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

s = list(S)

max = 0
for i in range(1,N-1):
    count = 0
    X = s[0:i]
    Y = s[i:N]
    x = list(set(X))
    y = list(set(Y))
    for j in x:
        if j in y:
            count += 1

    if count > max:
        max = count

print(max)

Solution (Python):
n=int(input())
s=input()
m=0
for i in range(n-1):
    x=s[:i]
    y=s[i:]
    x=set(x)
    y=set(y)
    z=x.intersection(y)
    m=max(len(z),m)
print(m)

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

alpha="abcdefghijklmnopqrstuvwxyz"

count=0
max=0

for i in range(1,n):
    x=s[:i]
    y=s[i:]
    for j in range(len(alpha)):
        if alpha[j] in x and alpha[j] in y:
            count+=1
    if count>max:
        max=count
    count=0

print(max)

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

mx = 0



for i in range(0, n):
    f = s[:i]
    b = s[i:]

    
    res = 0
    l = []
    
    for fi in f:
        
        if fi in b:
            
            if not fi in l:
                l.append(fi)
                res += 1
    

    if res > mx:
        
        mx = res

print(mx)

Solution (Python):


import math
import sys
import itertools
import numpy as np

n =int(input())

s = list(input())
num =[]
alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
for i in range(1,n,1):
    x = []
    y = []
    for j in range(0,i,1):
        x.append(s[j])
    for j in range(i,n,1):
        y.append(s[j])
    answer = 0
    for a in alphabet:
        if (a in x) and (a in y):
            answer += 1
    num.append(answer)


print(max(num))

Solution (Python):

num = int(input())
str = input()
alphabets = [chr(ord('a') + i) for i in range(26)]

answer=0

for i in range(1, num):
    strLeft = str[0:i]
    strRight = str[i:num]
    common=0
    for j in alphabets:
        if ((j in strLeft) and (j in strRight)):
            common+=1
    if(answer < common):
        answer=common

print(answer)

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

c = 0
for a in range(0, N-1):
	left = set(S[0:a])
	right = set(S[a:N])
	unio = left & right
	c = max(c, len(unio))

print(c)

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=list(input())
ans=0
for i in range(n):
    count=0
    x=s[:i+1]
    y=s[i+1:]
    setx=set(x)
    for j in setx:
        if j in y:
            count+=1
    ans=max(ans,count)
print(ans)

Solution (Python):
import re

if __name__ == '__main__':
	N = int(input())
	S = input()
	res = [0 for _ in range(N)]

	for i in range(N):
		a = S[:i]
		b = S[i:]
		count = set()

		for j in range(len(a)):
			for k in range(len(b)):
				if a[j] == b[k]:
					count.add(str(a[j]))
					break

		res[i] = len(count)

	print(max(res))

Solution (Python):
N = int(input())
s = input()
max = 0
for i in range(N):
    set_a = set(s[0:i])
    set_b = set(s[i:])
    num = set_a & set_b
    if len(num) > max:
        max = len(num)
print(max)

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

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

    print(maxlen)

Solution (Python):
import collections
n = int(input())
s = input()
ans = []
if n != 2:
    for i in range(1,n-1):
        counter = 0
        seg = s[0:i]
        another = s[i:n]
        d = collections.Counter(seg)
        for k in d:
            if k in another:
                counter += 1
        ans.append(counter)
    print(max(ans))
else:
    if s[0] == s[1]:
        print('1')
    else:
        print('0')

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

n = int(N)
tmp = ""
dic = {}
ans = 0

for i in range(n):
    tmp += S[i]
    dic_tmp = [False for i in range(123 - 97)]
    dic = [False for i in range(123 - 97)]

    for j in tmp:
        dic_tmp[ord(j) - 97] = True

    for j in range(i + 1, n):
        dic[ord(S[j]) - 97] = True

    ct = 0
    for k in range(len(dic)):
        if dic_tmp[k] == True and dic[k] == True:
            ct += 1

    ans = max(ans, ct)

print(ans)

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

both = 0
for i in range(1, n):
	a = list(set(s[0:i]))
	b = list(set(s[i:n]))
	botht = 0
	for al in a:
		if(al in b):
			botht += 1
	if(both < botht):
		both = botht
		
print(both)

Solution (Python):
if __name__ == '__main__':
    N = int(input())
    S = input()

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

Solution (Python):
N=int(input())
S=input()
ans = 0
for i in range(1,N):
    tmp1 = S[0:i]
    tmp2 = S[i:N+1]
    count=0
    for j in set(tmp1):
        if j in tmp2:
            count+=1
    ans = max(ans,count)

print(ans)

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


def create_map(s):
    m = {}
    for c in s:
        if c in m:
            m[c] += 1
        else:
            m[c] = 1
    return m


def common(m1, m2):
    c = 0
    
    
    for key in m1.keys():
        if key in m2:
            c += 1
    
    return c


m = 0
for i in range(1, len(S)):
    
    
    m1 = create_map(S[:i])
    m2 = create_map(S[i:])
    com = common(m1, m2)
    if com > m:
        m = com

print(m)

Solution (Python):
N = input()
S = list(input())
max_ = 0
alphabets = [chr(i) for i in range(97, 97+26)]
for i in range(1, len(S)-1):
    x = S[:i]
    y = S[i:]
    match = 0
    for a in alphabets:
        if a in x and a in y:
            match += 1
    if match > max_:
        max_ = match
print(max_)

Solution (Python):
n = int(input())
s = list(input())
l = []
count = 0
r = count
for i in range(n):
  a = s.pop(0)
  if (a in s) and (a not in l):
    count += 1
    if count > r:
      r = count
  elif (a not in s) and (a in l):
    count -= 1
  l.append(a)
print(r)

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

max = 0
for k in range(n):
    alpha = ""
    for i in range(k):
        for j in range(k, n):
            if s[i] == s[j]:
                if alpha.find(s[i]) < 0:
                    alpha += s[i]
    if len(alpha) > max:
        max = len(alpha)
print(max)

Solution (Python):
N = int(input())
s = list(input())
count = [0] * N

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

Solution (Python):



a = int(input())
s = input()

temp = []
for i in range(1,a):
    x = s[:i]
    y = s[i:]
    x = set(list(x))
    y = set(list(y))
    temp.append(len(x & y))


print("{}".format(max(temp)))

Solution (Python):
import math
import numpy as np


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

count = 0

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

print(count)

Solution (Python):
from collections import Counter
N = int(input())
S = input()
ans = 0 
for i in range(1,N):
    temp = list(set(S[0:i]))
    temp2 = list(set(S[i:N]))
    temp_ans =0
    for j in range(len(temp)):
        if temp[j] in temp2:
            temp_ans += 1
    if temp_ans>ans:
        
        
        ans = temp_ans
        
        
print(ans)

Solution (Python):
import sys
if __name__ == "__main__":
    N = int(input())
    S = input()
    max = 0
    for i in range(1, N):
        s1 = S[0:i]
        s2 = S[i:N+1]
        buf = list(set(s1))
        buf2 = list(set(s2))



        cnt = 0
        for i in range(len(buf)):
            if buf[i] in buf2:
                cnt += 1

        if cnt > max:
            max = cnt
    print(max)

Solution (Python):
def m():
    n = int(input())
    s = str(input())
    ans = 0
    for i in range(1, n):
        cnt = 0
        left = set(s[i:])
        right = set(s[:i])
        for j in left:
            if j in right:
                cnt +=1
        ans = max(cnt, ans)
    return ans

print(m())

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

ans = 0
for i in range(1, n):
    x = s[:i]
    y = s[i:]

    setX = set(x)
    setY = set(y)
    
    ans = max(ans, len(setX & setY))

print(ans)

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

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

res = [None] * n

for i in range(n):
    l = s[:i]
    r = s[i:]
    cnt = 0
    chk_s = ""

    for j in range(i):
        if not l[j] in chk_s:
            chk_s += l[j]
            if l[j] in r:
                cnt += 1

    else:
        res[i] = cnt

print(max(res))

Solution (Python):
N = int(input())
str = input()
str_list=list(str)
ans_list=[]
for i in range (N):
  str_first = str_list[0:i+1]
  str_second = str_list[i+1:]
  answer = len(list(set(str_first) & set(str_second)))
  ans_list.append(answer)
  
print(max(ans_list))

Solution (Python):
import collections

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

for i in range(n-1):
  front = collections.Counter(s[:i+1])
  back = collections.Counter(s[i+1:])
  number = len(front.keys() & back.keys())
  if number > max_number:
    max_number = number

print(max_number)

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

chars = list(S)
ans = 0
for i in range(N-1):
  set_a = set(chars[0:i+1])
  set_b = set(chars[i+1:])
  ans = max(ans, len(set_a & set_b))
print(ans)

Solution (Python):
n = int(raw_input())
s = [c for c in raw_input()]

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

print r

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



max = 0
for i in range(1, N):
    sum = 0
    
    
    forward = list(set(S[:i]))
    back = list(set(S[i:N]))
    for j in range(len(forward)):
        if forward[j] in back:
            sum += 1
    if sum > max: max = sum

print(max)

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

s = input()

result = 0
for i in range(1, len(s)):
    f_s = s[:i]
    b_s = s[i:]


    
    f_s_set = set(f_s)
    b_s_set = set(b_s)
    
    matched_s = list(f_s_set & b_s_set)
    if(len(matched_s) > result):
        result = len(matched_s)

print(result)

Solution (Python):
N = int(input())
S = list(input())
c = []
for i in range(1,N):
    a = S[:i]
    b = 0
    d = S[i:]
    for j in set(a):
        if j in d:
            b += 1
    c.append(b)

print(max(c))

Solution (Python):

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

    m = 0
    for i in range(1, len(s)):
        s1 = set()
        s2 = set()
        for x in s[0:i]:
            s1.add(x)
        for x in s[i:]:
            s2.add(x)
                
        m = max(m, len(s1 & s2))

    print(m)

if __name__ == '__main__':
    main()

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

Solution (Python):
N = int(input())
S = input()
max = 0
lis = []
for i in range(N):
    X = S[0:i]
    Y=S[i:N]
    X = list(set(X))
    Y = list(set(Y))
    lis = list(set(X) & set(Y))
    l = len(lis)
    if(l>max):max=l

print(max)

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

Solution (Python):
n = int(raw_input())
q = raw_input()

m = -1

for a in range(len(q)):
  dic1 = {}
  dic2 = {}
  buf = 0
  for b in range(len(q)):
    if a > b: dic1[ q[b] ] = 1
    else: dic2[ q[b] ] = 1

  for z in dic1:
    if z in dic2:
      buf += 1
  if m < buf:
    m = buf
print m

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

result = 0
for i in range(n-1):
  pre = set()
  suf = set()
  for j in range(i+1):
    pre.add(s[j])
  for k in range(i+1,n):
    suf.add(s[k])
  result = max(result,len(pre&suf))
print(result)

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

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

maxCount = 0

if N == 2:
    print(len(set(S[0])&set(S[-1])))
else:
    for i in range(N):
        commonCount = len(set(S[0:i+1])&set(S[i+1:]))
        if maxCount < commonCount:
            maxCount = commonCount
    print(maxCount)

Solution (Python):

"""
Created on Sat May 26 21:05:34 2018

@author: maezawa
"""

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

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

print(ans)

Solution (Python):
n = int(input())
t = str(input())
ans = 0
for i in range(1,len(t)):
    
    left = list(t[:i])
    right = list(t[i:])
    
    kyoutuu = set(left) & set(right)
    j = len(list(kyoutuu))
    if ans < j:
        ans = j
print(ans)

Solution (Python):


import os
import sys

def main():
    result = 0
    list_length = int(input())
    data = list(input())
    for i in range(list_length):
        c = and_count(data[:i], data[i:])
        if result < c:
            result = c
    print(result)

def and_count(l1, l2):
    s1 = set(l1)
    s2 = set(l2)
    return len(list(s1 & s2))

if __name__ == '__main__':
    main()

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

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

print(m)

Solution (Python):
def main():
    n, s = int(input()), input()

    c_lst = []
    for i in range(1, n):
        s1, s2 = s[:i], s[i:]

        s1_dic = {chr(j):0 for j in range(ord('a'), ord('a')+26)}
        for j in range(len(s1)):
            s1_dic[s1[j]] = s1_dic.get(s1[j], 0) + 1

        s2_dic = {chr(j): 0 for j in range(ord('a'), ord('a') + 26)}
        for j in range(len(s2)):
            s2_dic[s2[j]] = s2_dic.get(s2[j], 0) + 1

        cnt = 0
        for k in s1_dic:
            if s1_dic[k] != 0 and s2_dic[k] != 0:
                cnt += 1

        c_lst.append(cnt)

    print(max(c_lst))


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
s = list(input())
max_word = 0
for i in range(1, n):
    set_s1 = set(s[:i])
    set_s2 = set(s[i:])

    sorted(set_s1)
    sorted(set_s2)
    
    cnt = 0
    for r in set_s1:
        for t in set_s2:
            if r == t:
                cnt += 1
                max_word = max(cnt, max_word)
    
print(max_word)

Solution (Python):
n = int(input())
t = str(input())
ans = 0
for i in range(1,len(t)):
    
    left = list(t[:i])
    right = list(t[i:])
    
    kyoutuu = set(left) & set(right)
    j = len(list(kyoutuu))
    if ans < j:
        ans = j
print(ans)

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

max_chars = 0
for i in range(1, len(s)):
    x = s[:i]
    y = s[i:]
    

    cnt = 0
    for char in set(x):

        if char in y:
            cnt += 1
        max_chars = max(max_chars, cnt)

print(max_chars)

Solution (Python):
N = int(input())
S = list(input())
m = 0
for n in range(N-1):
    S1 = set(S[0:n+1])
    S2 = set(S[n+1:])
    S3 = S1 & S2
    m = max(m, len(S3))

print(m)

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

Solution (Python):
N, S = int(input()), input()
res = 0
def cmn_chars(A, B):
    a_set, b_set = set(A), set(B)
    return len(a_set.intersection(b_set))

res = cmn_chars(S[:len(S)//2], S[len(S)//2:])

for idx in range(res, len(S) - res):
    res = max(cmn_chars(S[:idx], S[idx:]), res)

print(res)

Solution (Python):
from collections import Counter
n = int(input())
s = list(input())
r = 0
for i in range(n):
  s1 = set(s[:i+1])
  s2 = set(s[i+1:])
  r = max(r, len(s1.intersection(s2)))
print(r)

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

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

print(R)

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

Solution (Python):
N = int(input())
S = input()
maxans = 0
for i in range(1, N):
    Xs = set([c for c in S[:i]])
    Ys = set([c for c in S[i:]])
    maxans = max(len(Xs.intersection(Ys)), maxans)

print(maxans)

Solution (Python):

N = int(input())

text = input()

ans = -1
for i in range(N-1):
	X = text[0:i+1]
	Y = text[i+1:N]
	X_alpha = [0]*27
	Y_alpha = [0]*27
	for x in X:
		X_alpha[ord(x)-ord("a")] = 1
	for y in Y:
		Y_alpha[ord(y)-ord("a")] = 1
		
	for j in range(27):
		X_alpha[j] = X_alpha[j] * Y_alpha[j]
	
	ans = max(ans,sum(X_alpha))
print(ans)

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

S = list(input())

result = 0
for i in range(1, N - 1):
    left_S = list(set(S[:i]))
    right_S = list(set(S[i:]))
    tmp = 0
    for j in left_S:
        if j in right_S:
            tmp += 1

    result = max(result, tmp)

print(result)

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

b = 0

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

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

ans = 0

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

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

strMap = {}
for i in range(0,N):
    if S[i] not in strMap.keys():
        strMap[S[i]] = [i]
    else:
        if len(strMap[S[i]]) == 1:
            strMap[S[i]].append(i)
        else:
            strMap[S[i]][1] = i

max = -10

for i in range(len(S)):
    thisSum = 0
    for key in strMap.keys():
        if len(strMap[key]) > 1:
            if strMap[key][0] <= i and i <= strMap[key][1]:
                thisSum += 1
    if thisSum > max:
        max = thisSum

print(max)

Solution (Python):
def abc098_b():
    import numpy as np
    n = int(input())
    s = input()
    counts = []
    if len(s) == 2:
        return [0,1][s[0] == s[1]]
    for i in range(1, n - 1):
        x = s[:i]
        y = s[i:]
        count = 0
        for let in set(x):
            if let in set(y):
                count += 1
        counts.append(count)
    return np.max(counts)


print(abc098_b())

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

max_char = 0
for k in range(1, N):
    num_of_char = len(set(S[:k]) & set(S[k:]))
    if max_char < num_of_char:
        max_char = num_of_char
print(max_char)

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

print(ans)

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

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

alphabet = "abcdefghijklmnopqrstuvwxyz"

ans = 0
for i in range(N):
        ans_tmp = 0
        for c in alphabet:
                if (c in S[:i]) and (c in S[i:]):
                        ans_tmp += 1
        if ans < ans_tmp:
                ans = ans_tmp

print(ans)

Solution (Python):
n = int(input())
s = input()
ans = 0
for i in range(n):
    a = list(set(s[:i]))
    b = list(set(s[i:]))
    sum = 0
    dict = {}
    for j in a:
        if j in dict:
            dict[j] += 1
        else:
            dict[j] = 1
    for j in b:
        if j in dict:
            dict[j] += 1
        else:
            dict[j] = 1
    for j in dict.values():
        if j >= 2:
            sum += 1
    ans = max(ans,sum)
print(ans)

Solution (Python):
n=int(input())
s=input()
out=0
for i in range(n-1):
    num=len(set(list(s)[:i+1]).intersection(set(list(s)[i+1:])))
    if num>out:
        out=num
print(out)

Solution (Python):
def count(a, b):
    c = 0
    for i in range(26):
        t = chr(ord('a') + i)
        if t in a and t in b:
            c += 1
    return c

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

print(max([count(s[:i], s[i:]) for i in range(n + 1)]))

Solution (Python):
N = int(input())
S = input()
max_num = 0
for i in range(N):
    s1 = S[:i]
    s2 = S[i:]
    num = len(set(s1) & set(s2))
    max_num = num if max_num < num else max_num
print(max_num)

Solution (Python):
def main():
    N = int(input())
    S = input()
    count = [0 for _ in range(N)]

    for i in range(1,N):
        s1 = S[:i]
        s2 = S[i:]
        a = ""
        for s in s1:
            if (s in a)==False:
                a += s
                if s in s2:
                    count[i] += 1
    return max(count)

if __name__ == "__main__":
    print(main())

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


count_list = []
for index in range(1, len(s)):
    a = s[:index]
    b = s[index:]

    kind_a = set(a)
    kind_b = set(b)

    count = 0
    for c in kind_a:
        if c in kind_b:
            count+=1
    count_list.append(count)

print(max(count_list))

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

ans = 0
for i in range(N):
    count = 0
    closed = []
    for j in range(i):
        if S[j] not in closed and S[j] in S[i:N]:
            count += 1
            closed.append(S[j])

    
    ans = max(ans, count)

print(ans)

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

max_num = 0
for i in range(N):
    
    count = 0
    left = S[:i]
    right = S[i:]
    
    

    left_uni = list(set(left))
    right_uni = list(set(right))
    
    

    for l in left_uni:
        if l in right_uni:
            count += 1

    

    if count > max_num:
        max_num = count


print(max_num)

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

m = 0

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

    inter = set(s1).intersection(set(s2))

    m = max(len(inter), m)

print(m)

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

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

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

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

Solution (Python):
import collections
N, S = int(input()), input()
ans = 0
for i in range(N+1):
    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-1):
    x = s[:i+1]
    y = s[i+1:]
    tmp = 0
    subset = set()
    for string in x:
        if string in y and string not in subset:
            tmp += 1
            subset.add(string)
    ans = max(ans, tmp)

print(ans)

Solution (Python):
n=int(input())
s=input()
r=0
for i in range(n):
    a=set(s[:i])
    b=s[i:]
    m=0
    for k in a:
        if b.find(k)>=0: 
            m+=1
    r=r if r>m else m
print(r)

Solution (Python):
n = input()
s = list(input())
res = 0
for i in range(1, len(s)):
    tmp = 0
    x = s[:i]
    y = s[i:]
    mita = []
    for k in x:
        if k in y and k not in mita:
            tmp += 1
        mita.append(k)
    res = max([res, tmp])
print(res)

Solution (Python):
n = input()
n = input()
ans = 0
for i in range(len(n)):
    a = n[0:i+1]
    b = n[i+1:len(n)]
    al = sorted(list(set(list(a))))
    bl = sorted(list(set(list(b))))
    temp = 0
    for j in range(len(al)):
        if al[j] in bl:
            temp += 1
    if ans < temp:
        ans = temp
print(ans)

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

for i in range(1,len(S)):
    F=S[:i]
    G=S[i:]

    X=set(F)

    count=0

    for j in X:
        if j in G:
            count=count+1

    maxcount=max(count,maxcount)

print(maxcount)

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

def solve(s,s2):
  cnt=set(s.strip())
  cnt2=set(s2.strip())
  return len(cnt&cnt2)
  
ans=0
for i in range(1,N-1):
  ans=max(ans,solve(S[:i],S[i:]))

print(ans)

Solution (Python):
N = int(input())
S = input()
ans = 0
for i in range(N-1):  
    n = 0
    right = S[i+1:]
    for c in list(set(S[:i+1])):
        if c in right:
            n += 1
    ans = max(ans, n)


print(ans)

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

ans=0
for i in range(N):
	t1=set(S[:i])
	t2=set(S[i:])
	tmp=len(t1 & t2)
	ans=max(ans,tmp)

print ans

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

ans = 0
for i in range(n-1):
    n_list = []
    x = s[:i+1]
    y = s[i+1:]
    for j in range(i):
        if x[j] in y:
            n_list.append(x[j])
    for j in range(n-1-i):
        if y[j] in x:
            n_list.append((y[j]))
    if len(set(n_list)) > ans:
        ans = len(set(n_list))

print(ans)

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

import collections
import string
ans = 0
for i in range(N):
  X = S[:i]
  Y = S[i:]
  cntX = collections.Counter(X)
  cntY = collections.Counter(Y)
  
  tmp = 0
  for c in string.ascii_lowercase:
    tmp += 0 if min(cntX[c], cntY[c]) == 0 else 1
  ans = max(ans, tmp)
print(ans)

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

max_num = 0

for i in range(1, N):
    common = set()
    X = S[:i]
    Y = S[i:]
    for c in X:
        if c in Y:
            common.add(c)
    if len(common) > max_num:
        max_num = len(common)

print(max_num)

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

output = 0
for i, pivot in enumerate(s):
    x = s[:i]
    y = s[i:]
    dic = {}
    out = 0
    for c in x:
        if not c in dic:
            dic[c] = 1
    for c in y:
        if c in dic:
            out += 1
            del dic[c]
    if out > output:
        output = out

print (output)

Solution (Python):
N = int(input())
S = list(input())
count = 0
for i in range(N+1):
    s1 = set(S[:i])
    s2 = set(S[i:])
    count = max(count,len(s1.intersection(s2)))
print(count)

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

print(c)

Solution (Python):
N = int(input())
S = input()
top = 0
for i in range(len(S)):
  a = S[:i]
  b = S[i:]
  a = set(a)
  b = set(b)
  a = list(a)
  b = list(b)
  c = len(a) + len(b) - len(set(a+b))
  top =  max(c,top)
print(top)

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

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

Solution (Python):





if __name__ == '__main__':
    n = int(input())
    s = input()
    result = 0

    for i in range(1, len(s)):
        tmp = set(s[:i]) & set(s[i:])
        result = max(len(tmp), result)

    print(result)

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