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):
    conj = set(S[:i]) & set(S[i:])
    ans = max(ans, len(conj))

print(ans)

Solution (Python):
import sys

stdin = sys.stdin

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

tmp = 0
ans = 0
for i in range(1,n):
    for j in set(s[0:i]):
        if j in set(s[i:]):
            tmp += 1
    ans = max(ans, tmp)
    tmp = 0
print(ans)

Solution (Python):

if __name__ == "__main__":
    n = int(input())
    s = input()
    ans = float('-inf')
    for end in range(1,n):
        ans = max(ans, len([tmp for tmp in list(set(s[0:end])) if list(set(s[end:n])).count(tmp) > 0]))
    else:
        print(ans)

Solution (Python):
n=int(input())
s=input()
slmax=0
for i in range(1,n):
    sa=set(s[:i])
    sb=set(s[i:])
    andl=len(sa&sb)
    if slmax<andl:
        slmax=andl
print(slmax)

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

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

mm = 0

for i in range(1,n):
    s1 = s[0:i]
    s2 = s[i:n]
    a = set(s1)
    b = set(s2)
    c = a & b
    mm = max(mm, len(c))

print(mm)

Solution (Python):
n=int(raw_input())
s=raw_input()
res=0
for i in xrange(len(s)):
 s1=s[:i]
 s2=s[i:]
 t1=set(list(s1))
 t2=set(list(s2))
 t3=t1 & t2
 res=max(res,len(t3))
print res

Solution (Python):
n = int(raw_input())
s = raw_input()
mx = 0
for i in range(n):
    s1 = set(list(s[:i]))
    s2 = set(list(s[i:]))
    mx = max(mx, len(s1.intersection(s2)))
print mx

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

result = 0
for i in range(1, n-1):
    x = list(set(s[:i]))
    y = list(set(s[i:]))
    temp = len(x+y) - len(set(x+y))
    if temp > result:
        result = temp

print(result)

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

Solution (Python):
N = int(input())
S = input()
max_count = 0
for i in range(1, N):
    X = set(list(S[:i]))
    Y = S[i:]
    count = 0
    for c in X:
        if c in Y:
            count += 1
    max_count = max(max_count, count)
print(max_count)

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

for i in range(N):
    S1 = set(S[:i])
    S2 = set(S[i:])

    count = max(count, len(S1 & S2))

print(count)

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

print(ans)

Solution (Python):
num=int(input())
word=str(input())
n_th = 0
for i in range(num):
    s1=word[:i]
    s2=word[i:]
    n=0
    for a in 'abcdefghijklmnopqrstuvwxyz':
        if (not s1.find(a) == -1) and (not s2.find(a) == -1):
            n += 1
    if n>n_th:
        n_th=n
print(n_th)

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

ans = 0
for i in range(1, n):
    f = s[:i]
    b = s[i:]
    cnt = 0
    for c in [chr(j + ord('a')) for j in range(26)]:
        if c in f and c in b:
            cnt += 1
    ans = max(ans, cnt)

print(ans)

Solution (Python):
N = int(input())
S = list(input())
count = 0
for i in range(1, N):
    pre_S = set(S[:i])
    post_S = set(S[i:])
    kyoutu_S = pre_S & post_S
    if count < len(kyoutu_S):
        count = len(kyoutu_S)

print(count)

Solution (Python):
def charToInt(c):
    return ord(c) - ord("a")
 
def stringToFlags(s):
    t = [False for i in range(26)]
    for i in range(len(s)):
        t[charToInt(s[i])] = True
    return t
 
def B(n, s):
    max = 0
    for i in range(1, n):
        xflags = stringToFlags(s[0:i])
        yflags = stringToFlags(s[i:n])
        
        count = 0
        for i in range(26):
            if xflags[i] and yflags[i]:
                count += 1
                if count > max:
                    max = count
    return max
 
n = int(input())
s = input()
print(B(n, s))

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

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

print(m)

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    s = S()
    r = 0
    for i in range(n):
        a = set(collections.Counter(s[:i]).keys())
        b = set(collections.Counter(s[i:]).keys())
        r = max(r, len(a&b))

    return r




print(main())

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

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

A = [chr(i) for i in range(ord("a"), ord("a")+26)]

ans = 0
for i in range(N+1):
    S1 = S[:i]
    S2 = S[i:]
    cnt = 0
    for a in A:
        if a in S1 and a in S2:
            cnt += 1
    ans = max(ans, cnt)

print(ans)

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

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

    c_lst = []
    for i in range(n):
        s1, s2 = set(s[:i]), set(s[i:])
        c_lst.append(len(s1&s2))

    print(max(c_lst))


if __name__ == '__main__':
    main()

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

for i in range(n):
  front_bucket[ord(s[i])-97]+=1
for i in range(n):
  back_bucket[ord(ss[i])-97]+=1
  front_bucket[ord(ss[i])-97]-=1
  a=0
  for j in range(26):
    if front_bucket[j]*back_bucket[j]>0:
      a+=1
  ans=max(ans,a)

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(raw_input())
S = raw_input()
ret = 0
for i in range(N):
  l = S[:i]
  r = S[i:]
  u = set(l) & set(r)
  ret = max(ret, len(u))
print ret

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

Solution (Python):
import string

def f(s, t):
    ret = 0
    for c in string.ascii_lowercase:
        found_s = False
        found_t = False
        for i in range(len(s)):
            if s[i] == c:
                found_s = True
                break
        for i in range(len(t)):
            if t[i] == c:
                found_t = True
                break
        if found_s and found_t:
            ret += 1
    return ret
    
if __name__ == '__main__':
    n = int(input())
    s = input()

    ans = 0
    for i in range(n + 1):
        
        
        
        tmp = f(s[:i], s[i:]) 
        ans = max(ans, tmp)
    print(ans)

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

A=[]

for i in range(N-1):
    left=set(S[:i+1])
    right=set(S[i+1:])
    C= left & right
    B=len(C)
    A.append(B)
    
        
print(max(A))

Solution (Python):
N = int(input())
S = list(str(input()))
countlist=[]
for i in range(0,N):
    s1 = set(S[:i])
    s2 = set(S[i:])

    matched_list=list(s1 & s2)
    countlist.append(len(matched_list))

ans = max(countlist)
print(ans)

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

Solution (Python):
import string

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

ans = 0
for i in range(n + 1):
    
    
    
    a, b = s[:i], s[i:]
    tmp = 0
    for c in string.ascii_lowercase:
        if (c in a) and (c in b):
            tmp += 1
    ans = max(ans, tmp)
print(ans)

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

num=[]
for i in range(0,N-1):
	icchi=[]
	p_list=[]
	q_list=[]
	for p in range(0,i+1):
		p_list.append(S[p])
	for q in range(i+1,N):
		q_list.append(S[q])
	for x in range(0,len(p_list)):
		for y in range(0,len(q_list)):
			if(p_list[x]==q_list[y]):
				icchi.append(p_list[x])
				break
	num.append(len(set(icchi)))
print(max(num))

Solution (Python):
N = int(input())
S = input()
ans=[]
for i in range(N):
    x =S[:i]
    y=S[i:]
    a = 0
    xs = set()
    ys = set()
    for s in x:
        xs.add(s)
    for s in y:
        ys.add(s)  
    ans.append(len(xs&ys))
print(max(ans))

Solution (Python):
length = int(input())
chars = list(input())

maxOfKinds = 0

index = 0

while(index != len(chars)):
    numOfEquals = 0
    for i in range(0, index + 1):
        isExisted = False
        for k in range(0, i):
            if chars[i] == chars[k]:
                isExisted = True
        if isExisted == True:
            continue
        for j in range(index + 1, len(chars)):
            if chars[i] == chars[j]:
                numOfEquals += 1
                break
    if maxOfKinds < numOfEquals:
        maxOfKinds = numOfEquals
    index += 1

print(maxOfKinds)

Solution (Python):
def abc098_b():
    n = int(input())
    s = input()
    count_max = 0
    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
        count_max = max(count,count_max)
    return count_max

print(abc098_b())

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

Solution (Python):
alp=[]
alp+="abcdefghijklmnopqrstuvwxyz"
li=[]
n = int(input())
li+=input()
saidai = 0
for i in range(n):
    count = 0
    lia = li.copy()
    lib = []
    for j in range(i):
        lib += lia.pop()
    for t in range(26):
        if alp[t] in lia and alp[t] in lib:
            count += 1
    if saidai < count:
        saidai = count
print(saidai)

Solution (Python):
n=int(input())
a=input()
l = []
for i in range(0, n):
    l.append(a[i])
t0=[]
for k in range(0, n):
    l1 = l[0:k]
    l2 = l[k: n]
    s1 = set(l1)
    s2 = set(l2)
    t = s1 & s2
    t0.append(len(t))
print(max(t0))

Solution (Python):
N = int(raw_input())
S = list(raw_input())
ans = 0
for n in range(N):
 B = set(S[:n])
 E = set(S[n:])
 c = 0
 for b in B:
  if b in E:
   c += 1
 if c > ans:
  ans = c
print ans

Solution (Python):

n=int(input())
s=input()
origin=[]
origin=list(s)
s1=[]
s2=[]
i=0
j=0
k=0
a=0
an=0
while(i<=n-1):
    while(j<=i):
        s1.append(origin[j])
        j=j+1
    while(j<=n-1):
        s2.append(origin[j])
        j=j+1
    j=0
    s1=list(set(s1))
    s2=list(set(s2))

    while(j<=len(s1)-1):
        while(k<=len(s2)-1):
            if(s1[j]==s2[k]):
                a+=1
            k+=1
        k=0
        j+=1
    j=0
    i+=1
    s1=[]
    s2=[]
    if(an<a):
        an=a
    a=0
print(an)

Solution (Python):



input1 = raw_input()
input2 = raw_input()

N = int(input1)
S = input2


cutdic = {}

for i in range(N):
    count = 0
    X = S[:i]
    Y = S[i:]
    setX = set(X)
    
    for j in setX:
        if j in Y:
            count += 1
        cutdic[str(i) + "," + str(j)] = count

print (max(cutdic.values()))

Solution (Python):


N = int(input())
S = input().strip()

max_cnt = -1

for k in range(1,N):
    s1 = S[:k]
    s2 = S[k:]
    

    cnt = len(set(s1) & set(s2))
    max_cnt = max(max_cnt, cnt)

print(max_cnt)

Solution (Python):

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

count = 0
temp = 0

for i in range(1,N):
    temp = 0
    s_tmp = S
    for j in range(i):
        if( s_tmp[i:].find(s_tmp[j]) >= 0 and s_tmp[j]!=','):
            temp = temp + 1;
            s_tmp = s_tmp.replace(s_tmp[j], ",")
            if(temp>count):
                count = temp
        
print(count)

Solution (Python):

N = input()
S = input()
N = int(N)
count = []

for i in range(N):
    times = 0
    left = S[:i]
    right = S[i:]
    for j in set(left):
        if j in set(right):
            times += 1
    count.append(times)
print(max(count))

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

for i in range(1,N):
    a = S[:i]
    b = S[i:]
    k = 0
    for j in range(len(a)):
        if a[j] not in a[:j]:
            if a[j] in b:
                k+=1
    if k>l:
        l = k
        
print(l)

Solution (Python):

N = input()
S = raw_input()

max_n = 0

for i in range(N-1):
    x = S[0:i+1]
    y = S[i+1:N]
    x1 = list(set(x))
    y1 = list(set(y))
    rx = len(x1)
    ry = len(y1)
    count = 0
    for j in range(rx):
        for k in range(ry):
            if y1[k] in x1[j]:
                count = count + 1
    if count > max_n:
        max_n = count

print(max_n)

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

counter = []
for i in range(1, N):
    temp = []
    temp.append(S[0:i])
    temp.append(S[i:N])
    matched_set = list(set(temp[0]) & set(temp[1]))
    counter.append(len(matched_set))

print(max(counter))

Solution (Python):

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


ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
max = 0
count = 0


for i in range(len(s)):
  count = 0
  a = (s[i:n])
  b = (s[0:i])
  for j in range(len(ascii_lowercase)):
    if (a.count(ascii_lowercase[j]) > 0 and b.count(ascii_lowercase[j]) > 0):
      count += 1
  if (max < count):
    max = count
print (max)

Solution (Python):

"""
Created on Sat May 26 21:45:21 2018

@author: sakas
"""
N = int(input())
S = input()
arr = set()
ray = set()
s = list(S)
j = 0
for i in range(len(s)):
   arr = set(list(S[:int(i)]))
   ray = set(list(S[int(i):]))
   if j < int(len(arr & ray)):
       j = len(arr & ray)
print(j)

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

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

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

for x in range(1,n):
    u = [i for i in s[0:x] if i in s[x:(n+1)]]
    l = len(set(u))
    m = max(l, m)

print(m)

Solution (Python):
from sys import stdin
n = int(stdin.readline())
a = stdin.readline().strip()
ans = 0
b = "abcdefghijklmnopqrstuvwxyz"
for i in xrange(n):
 x = a[:i]
 y = a[i:]
 cur = 0
 for i in b:
  if i in x and i in y:
   cur += 1
 ans = max(ans,cur)
print ans

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

cnt = set()
for i in range(1, N):
    X = S[:i]
    Y = S[i:]
    x_set = set(X)
    y_set = set(Y)
    c = len(list(x_set & y_set))
    cnt.add(c)
print(max(cnt))

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

Solution (Python):

n = int(input())
s = input()
S = list(s)
max = 0
tmp = 0
for i in range(1,n+1):
    tmp = 0
    for j in range(i):
        if S[j] in s[i:n+1] and S[j] not in s[0:j]:
            tmp += 1
    if tmp > max:
        max = tmp
print(max)

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

Solution (Python):


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

def sentenceCount(sx, sy):
    tmp = ''
    count = 0
    for char in sx:
        if sy.count(char) > 0 and not char in tmp:
            count = count + 1
            tmp = tmp + char
    
    return count

cnt = 0
for i in range(1, N):
    tmp = sentenceCount(S[:i], S[i:])
    if tmp > cnt:
        cnt = tmp

print(cnt)

Solution (Python):
N = int(input())
S = input()
length = len(S)
M = 0
for i in range(length):
    fir = set(S[:i])
    las = set(S[i:])
    l = len(fir & las)
    if l > M:
        M = l
print(M)

Solution (Python):
a = int(input())
b = str(input())

res = []
def finder(A,B):
    goi = 0
    for k in range(97, 97+26):
        num = chr(k)
        if num in A and num in B:
            goi += 1
    else:
        return goi

for i in range(1,a):
    c = b[0:i]
    d = b[i:a]
    tyu = finder(c,d)
    
    res.append(tyu)
else:
    bigg = max(res)
    print(bigg)

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

M = 0
for n in range(1,N) :
    set1 = set([])
    set2 = set([])
    I = set([])
    for c in (S[:n]) :
        set1.add(c)
    for d in (S[n:]) :
        set2.add(d)
    I = set1 & set2
    if(len(I)>M) :
        M = len(I)
print(M)

Solution (Python):
n=int(input())
x=input()
s=list(x)
list=[]
 
for i in range(n):
    a=0
    moji=[]
    for j in range(i):
        for k in range(n-i):
            if s[j]==s[k+i]:
                if s[j] not in moji:
                    a+=1
                    moji.append(s[j])
    list.append(a)
 
f=max(list)
print(f)

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

def count(s, c):
    for i in range(0, len(s)):
        idx = ord(s[i]) - ord('a')
        if idx < 30:
            c[idx] += 1

max = 0
for i in range(1, n):
    a = s[0:i]
    b = s[i:]
    ca = [0 for i in range(30)]
    cb = [0 for i in range(30)]
    count(a, ca)
    count(b, cb)

    t = 0
    for j in range(0, 26):
        if ca[j] > 0 and cb[j] > 0:
            t += 1
    if t > max:
        max = t
print(max)

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

m = 0
for i in range(1, n):
    sub1 = set(s[:i])
    sub2 = set(s[i:])
    count = 0
    for c in sub1:
        if c in sub2:
            count += 1
    if m < count:
        m = count


print(m)

Solution (Python):



N = int(input())

S = input()

max_v = 0
for i in range(1,N):
    sXY = set(list(''.join(list(S[:i])))) & set(list(''.join(list(S[i:]))))
    if max_v < len(sXY):
    	max_v = len(sXY)

print(max_v)

Solution (Python):
n = int(input())
s = list(input())
ans = 0
for i in range(1,n):
    cnt = 0
    flag = []
    for j in range(0,i):
        for k in range(i,n):
            if s[j]==s[k] and s[j] not in flag:
                cnt += 1
                flag.append(s[j])
                break

    ans = max(ans,cnt)

print(ans)

Solution (Python):
import sys

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

if n == 0 or n == 1:
    print(n)
    sys.exit()

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

    x_set = set(x)
    y_set = set(y)
    x_and_y = x_set & y_set
    z = len(x_and_y)
    if ans < z:
        ans = z
print(ans)

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

c = 0
x = ""
for i in range(n):
    a = 0
    x = s[0:i]
    y = s[i:n]
    for j in x:
        if j in y:
            y = y.replace(j, "")
            a += 1

        if a > c:
            c = a

print(c)

Solution (Python):
import copy

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

maxcount = 0
for i in range(1,n):
    count = 0
    X = set(s[:i])
    Y = set(s[i:])
    
    for j in X:
        for k in Y:
            if j == k:
                count += 1
        
    if maxcount < count:
        maxcount = count
        
print(maxcount)

Solution (Python):
N = int(input())
S = input()
lst = []
flag = True
for i in range(1,N):
    X = S[0:i]
    Y = S[i:N]
    xlst = list(X)
    ylst = list(Y)
    Zlst = list(set(xlst) & set(ylst))
    z = len(Zlst)
    lst.append(z)
    i=i+1
print(max(lst))

Solution (Python):
import string
import itertools


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

    front = [set()]
    for c in s:
        x = front[-1] | set([c])
        front.append(x)
        
    back = [set()]
    for c in reversed(s):
        x = back[0] | set([c])
        back.insert(0, x)
    
    m = 0
    for f, b in zip(front, back):
        x = f & b
        m = max(m, len(x))
    
    print(m)

main()

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

Solution (Python):


N = int(input())
S = list(map(str, input().split()))
s=list(S[0])
c=[]

for i in range(1,N):
    a_and_b = list(set(s[0:i]) & set(s[i:N]))
    c.append(int(len(a_and_b)))

print(max(c))

Solution (Python):



import copy


N = int(input())
S = list(input())
ans = []

for j in range(1,N-1,1):
	counter = 0
	S_hidari = []
	S_migi = []
	S_hidari = set(copy.copy(S[0:j]))
	S_migi = set(copy.copy(S[j:N]))
	for s_hidari in S_hidari:
		for s_migi in S_migi:
			if s_hidari == s_migi:
				counter += 1
	ans.append(counter)


if N == 2:
	if S[0] == S[1]:
		print("1")
	else:
		print("0")
	exit()
print(max(ans))

Solution (Python):
n = int(input())
s = str(input())
x_sum=[]
y_sum=[]
for i in range(n):
    x = s[0:i]
    y = s[i:n]
    x_sum.append(x)
    y_sum.append(y)
m = []
for i in range(1,n):
    x_list = list(x_sum[i])
    x_unique = list(set(x_list))
    l = 0
    for j in x_unique:
        if y_sum[i].find(j) > -1:
            l += 1
    m.append(l)
print(max(m))

Solution (Python):

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


S1 = []
S2 = []
score = 0
ans = 0
scorelist = []
alphabet = [chr(i) for i in range(97, 97+26)]
for i in range(N-1):
    S1 = S[0:i+1]
    S2 = S[i+1:N]
    score = 0
    for n in range(26):
        if alphabet[n] in S1:
            if alphabet[n] in S2:
                score += 1
        scorelist.append(score)
ans = max(scorelist)
print(ans)

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

for i in range(n):
	a = list(s[:i])
	b = list(s[i:])
	aset = set(a)
	bset = set(b)
	c = len(aset & bset)
	words.append(c)

print(max(words))

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

saidai = 0

for i in range(1,N):
    cnt = 0
    search = []
    tmp1 = S[0:i]
    tmp2 = S[i:N]
    for k in range(len(tmp1)):
        if tmp1[k] not in search:
            search.append(tmp1[k])
    for j in range(len(search)):
        if search[j] in tmp2:
            cnt += 1
    if saidai < cnt:
        saidai = cnt

print(saidai)

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


def mozisu(text, num):
    ans = 0
    wc = {}
    for i in text[:num]:
        wc[i] = True
    for i in text[num:]:
        if i in wc:
            if wc[i]:
                wc[i] = False
                ans += 1
    return ans

max = 0
for i in range(len(S)-1):
    x = mozisu(S, i+1)
    if x > max:
        max = x
print(max)

Solution (Python):
n = int(input())
s = input()
ans = 0
for i in range(1, n-1):
	s1 = set(list(s[:i]))
	s2 = set(list(s[i:]))
	c = len(list(s1 & s2))
	if c > ans:
		ans = c
print(ans)

Solution (Python):


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

alphabet = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u",
            "v", "w", "x", "y", "z"]

max_count = 0

for i in range(1, n):
    left = s[0:i]
    right = s[i:n]
    count = 0
    for x in alphabet:
        if left.find(x) != -1 and right.find(x) != -1:
            count += 1
    if max_count < count:
        max_count = count
        
print(max_count)

Solution (Python):
import string

N = int(input())
s = str(input())

alphabet = string.ascii_lowercase
num_list = []

for i in range(N):
    count_alphabet = [0 for k in range(len(alphabet))]
    first = s[i:]
    end = s[:i]
    for j in first:
        if j in end:
            count_alphabet[alphabet.index(j)] = 1
    num_list.append(count_alphabet.count(1))

print(max(num_list))

Solution (Python):
from sys import stdin

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

str = []
for i in range(N):
    str.append(S[i])

result = 0

for i in range(N-1):
    front = str[:i+1]
    tail = str[i+1:]
    tmp = len(set(front) & set(tail))
    if tmp > result:
        result = tmp

print(result)

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

s_list = list(set(S))
n_list = []

for i in range(1, N - 2):
    line1 = S[:i]
    line2 = S[i:]
    num = 0
    for c in s_list:
        _1 = line1.count(c)
        _2 = line2.count(c)
        if (_1 > 0 and  _2 > 0):
            num += 1
    n_list.append(num)

if (len(n_list) > 0):
    print(max(n_list))
else:
    print(0)

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

for i in range(len(S)-1):
    
    
    Foward=set(S[i+1:])
    Rear=set(S[:i+1])
    count_prev=res
    count=0

    for j in Foward:
        
        
        
        if(j in Rear):
            
            count+=1
            
    res=max(count,count_prev)
    
print(res)

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

Ans = 0

for i in range(len(S)):
	X = set(S[:i])
	Y=set(S[i:])
	numAND = len(X & Y)
	if numAND >= Ans:
		Ans = numAND
print(Ans)

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

Solution (Python):

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

k = []
r = []

for i in range(len(S)):
    
    s1 = S[0:i]
    s2 = S[i:len(S)]
    
    for j in range(len(s1)):
        if s2.find(s1[j:j+1]) != -1:
            
            if (s1[j:j+1] in k) == False:
                k.append(s1[j:j+1])
                
    r.append(len(k))
    k.clear()


r.sort()
r.reverse()
print(r[0])

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

r_count = 0

for x in range(N - 1):   
    a = list(S[0:x + 1])
    b = list(S[x + 1: N])
    a_u_l = list(set(a))
    b_u_l = list(set(b))
    count = 0
    for a_u in a_u_l:
        if a_u in b_u_l:
            count = count + 1
    if count >= r_count:
        r_count = count
        
print(r_count)

Solution (Python):
N = int(input())
a = list(input())
 
l = [] 
alphabet = 'abcdefghijklmnopqrstuvwxyz'

for i in range(N):
    count = 0
    x = a[:i]
    y = a[i:]
    for letter in alphabet:
        if letter in x and letter in y:
            count += 1
    l.append(count)
    
print(max(l))

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

Solution (Python):
n = int(input())
s = input()
counted = []
for i in range(1, n):
    c = 0
    counted_char = []
    for j in s[:i]:
        if j in s[i:] and j not in counted_char:
            c += 1
            counted_char.append(j)
    counted.append(c)

print(max(counted))

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

Solution (Python):


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

list1=["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"]
list2=[]
for i in range(1,N):
    
    count=0
    for j in range(26):
        if S[:i].count(list1[j])>=1 and S[i:].count(list1[j])>=1:
            count=count+1
    list2.append(count)



print(max(list2))

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

for i in range(n):
    a = set(s[:i+1])    
    b = set(s[i+1:])
    l = len(a & b)
    if l > max:
        max = l
print(max)

Solution (Python):
import copy

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

count = 0



for i in range(len(S)):
    left = S[0:i]
    right = S[i:]
    left = set(left)
    right = set(right)
    sumsum = left & right
    sumsum = len(sumsum)
    if sumsum > count:
        count = copy.deepcopy(sumsum)

print(count)

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

ans = 0
for i in range(n):
    x = s[0:i]
    y = s[i:n]
    temp = 0
    for ch in range(ord('a'), ord('z')+1):
        ch = chr(ch)
        if ch in x and ch in y:
            temp += 1
    ans = max(ans, temp)
print(ans)

Solution (Python):
N=int(input())
S=str(input())
a=[]
Slist=list(S)
for i in range(0,N):
    slice=S[0:i]
    slice=S[i:N]
    S1list=list(S[0:i])
    S2list=list(S[i:N])
    set1=set(S1list)
    set2=set(S2list)
    match=list(set1 & set2)
    a.append(len(match))
print(max(a))

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

Solution (Python):
n = int(input())
s = input()
l = {}
r = {}
ans = 0
nagasa = len(s)
for i in range(1, nagasa):
    l = set(s[0:i])
    r = set(s[i:nagasa+1])
    tmp = len(l&r)
    if ans < tmp:
        ans = tmp
print(ans)

Solution (Python):
from collections import Counter

N = int(input())
s= input()

M = 0

for i in range(N):
    temp = 0
    l1,l2 = s[:i],s[i:]
    n1 , n2 = Counter(l1), Counter(l2)
    for c in n1.keys():
        if c in n2.keys():
            temp += 1
    if temp >= M:
        M = temp

print (M)

Solution (Python):
input()
target = list(input())
ret = 0
for i in range(len(target)):
    bSet = set(target[:i])
    aSet = set(target[i:])
    inter = bSet & aSet
    if ret < len(inter):
        ret = len(inter)
print(ret)

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

lst = []
for i in range(1,len(s)):
    s1 = s[:i]
    s2 = s[i:]
    
    
    sls1 = []
    sls2 = []
    for j in range(len(s1)):
        sls1.append(s1[j])
    for j in range(len(s2)):
        sls2.append(s2[j])
    s1 = sls1
    s2 = sls2
    s1.sort()
    s2.sort()
    
    
    sls1 = [s1[0]]
    for j in range(1,len(s1)):
        if s1[j] != s1[j-1]:
            sls1.append(s1[j])
    sls2 = [s2[0]]
    for j in range(1,len(s2)):
        if s2[j] != s2[j-1]:
            sls2.append(s2[j])
    s1 = sls1
    s2 = sls2
    
    
    cnt = 0
    for j in range(len(s1)):
        for k in range(len(s2)):
            if s1[j] == s2[k]:
                cnt += 1
    lst.append(cnt)
lst.sort()

print(lst[-1])