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

def main():
    s = list(S)
    ans = 0
    for i in range(N):
        x = s[:i]
        y = s[i:]
        intersection = set(x) & set(y)
        ans = max(ans, len(intersection))
    print(ans)

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=str(input())
S1=""
S2=""
ans=0

for i in range(N):
    
    past=[]
    count=0
    S1="".join(S[0:i+1])
    
    S2="".join(S[i+1:len(S)])
    
    for j in range(len(S2)):

        if S1.rfind(S2[j])!=-1 and not(S2[j] in past):
            
            count+=1
            past.append(S2[j])
            
    
    ans=max(ans,count)

print(ans)

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

maxco=0

for i in range(len(s)):
    co=0
    le=s[0:i]
    ri=s[i:len(s)]
    for j in range(i):
        if le[j] not in le[0:j] and le[j] in ri :
            co+=1
    maxco=max(maxco,co)

print(maxco)

Solution (Python):
n=int(input())
s=list(input())
li_and=[]
for i in range(n):
    s_a=s[0:i+1]
    s_b=s[i+1:n]
    s_and = len(list(set(s_a) & set(s_b)))
    li_and+=[s_and]
print(max(li_and))

Solution (Python):
N = int(input())
s = input()
i = 1
li = []
charas = 'abcdefghijklmnopqrstuvwxyz'
while i < N:
  m = 0
  s1 = s[0:i]
  s2 = s[i:]
  for chara in charas:
    if chara in s1 and chara in s2:
      m += 1
  li.append(m)
  i += 1
print(max(li))

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

ans = 0

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

print(ans)

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

Solution (Python):
N = input()
A = input()
B =[i for i in A]
SUM = [0]*(len(B))
for i in range(len(B)):
    count=0
    C = B[:i]
    D = set(B[i:])
    for t in D:
        if C.count(t)>0:
            count+=1
            SUM[i] = count
print(max(SUM))

Solution (Python):
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())
atoz = [chr(i) for i in range(97,97+26)]

N = inp()
S = input()
ans = 0
for i in range(1,N):
	x = S[:i]
	y = S[i:]
	tmp = 0
	for s in atoz:
		if s in x and s in y:
			tmp += 1
	ans = max(tmp,ans)

print(ans)

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

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

Solution (Python):
N, S = (input() for i in 'NS')
res = 0
for i in range(int(N)):
    s, t = set(S[:i]), set(S[i:])
    res = max(res, len(s.intersection(t)))
print(res)

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

Solution (Python):
N = int(raw_input())
S = raw_input()
slist = []
for i in range(0, N):
	slist.append(S[i])
max = 0
for i in range(0, N):
	xlist = []
	for j in range(0, i):
		if slist[j] not in xlist:
			xlist.append(slist[j])
	ylist = []
	for j in range(i, N):
		if slist[j] not in  ylist:
			ylist.append(slist[j])
	cnt = 0
	for j in range(0, len(xlist)):
		if xlist[j] in ylist:
			cnt = cnt + 1
	if max < cnt:
		max = cnt

print max

Solution (Python):
N = int(input())
s = str(input())
types = []
for i in range(len(s)-1):
    x = list(s[:i+1])
    y = list(s[i+1:])
    x.sort()
    y.sort()
    x_str = []
    y_str = []
    count = 0
    for j in range(len(x)):
        if j == 0:
            x_str.append(x[0])
        else:
            if x[j-1] != x[j]:
                x_str.append(x[j])
    for j in range(len(y)):
        if j == 0:
            y_str.append(y[0])
        else:
            if y[j-1] != y[j]:
                y_str.append(y[j])
    for j in range(len(x_str)):
        if x_str[j] in y_str:
            count += 1
    types.append(count)
print(max(types))

Solution (Python):
def stringToCompare(x,y):
    r = []
    c = 0
    for i in range(len(y)):
        if x.count(y[i]):
            if y[i] not in r:
                c+=1
                r.append(y[i])
    return c

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

print(max([stringToCompare(S[0:i],S[i:N]) for i in range(0,N)]))

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

Solution (Python):

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

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

R = []

for i in range(N):
    s1 = list(set(list(S[:(i+1) ])))
    s2 = list(set(list(S[ (i+1):])))
    r = 0
    for s in s1:
        if (s in s2) == True:
            r += 1
    R.append(r)

print(max(R))

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

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

count_max=0
for i in range (N):
    left=S[:i]
    right=S[i:]
    count=0
    for j in range (len(alphabet)):
        if right.count(alphabet[j])>0 and left.count(alphabet[j])>0:
            count+=1
    if count>count_max:
        count_max=count
print(count_max)

Solution (Python):
N = int(input())
S = input()
key = 0
Count = []
cnt = 0
for i in range(N - 1):
    for j in range(i + 1):
        for k in range(j):
            if j == 0:
                break
            if S[j] == S[k]:
                
                key = 1
                break
            
        if key == 0:
            for k in range(i + 1, N):
               if S[j] == S[k]:
                    cnt += 1
                    
                    break

        key = 0
            
    Count.append(cnt)
    
    cnt = 0

print(max(Count))

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

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

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

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

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

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

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

    for j in range (i,n):
        right.add(s[j])
    
    both=right&left
    ans=max(ans,len(both))
    

print(ans)

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

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

print(ans)

Solution (Python):
N = int(input())
S = input()
LS = list(S)
count = 0
hantei = 0
alfabetto = [
"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):
    RLS = LS[0 : i]
    LLS = LS[i : N]

    for alfa in alfabetto:
        if (alfa in RLS) and (alfa in LLS):
            count += 1
    if hantei < count:
        hantei = count
    count = 0

print(hantei)

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

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

Solution (Python):
import collections
N = int(input())
S = input()
ans = 0
for i in range(1, N):
    left = S[:i]
    right = S[i:]
    count_left = collections.Counter(left)
    count_right = collections.Counter(right)
    count_left_unique = list(count_left.keys())
    count_right_unique = count_right.keys()
    cnt = 0
    for j in range(len(count_left_unique)):
        if(count_left_unique[j] in count_right_unique):
            cnt += 1
    ans = max(ans, cnt)
print(ans)

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

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

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


print(max(len(set(x).intersection(set(y))) for x,y in [(S[:i],S[i:]) for i in range(1, len(S))]))

Solution (Python):


from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


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


if __name__ == '__main__':
    main()

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

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


print(ans)

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

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

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

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

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


print(ans)

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

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

l_dict = {}
r_dict = {}

for c in s:
	r_dict[c] = 0
	l_dict[c] = 0

for c in s:
	r_dict[c] += 1

ans = 0
for c in s:
	l_dict[c] += 1
	r_dict[c] -= 1

	count = 0
	for k, v in l_dict.items():
		if v > 0:
			if r_dict[k] > 0:
				count += 1

	ans = max(ans, count)

print(ans)

Solution (Python):
n = int(input())
s = input()
c = 0
list_s = [sorted(list(set(s[:i]))) for i in range(1,n)]
list_l = [sorted(list(set(s[i:]))) for i in range(1,n)]
print(max([sum([1 if list_s[j][i] in list_l[j] else 0 for i in range(len(list_s[j]))]) for j in range(n-1)]))

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

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

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

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

Solution (Python):
res = -float('inf')
n=int(input())
s=input()
for i in range(1,n):
    tmp = 0
    x=s[:i]
    y=s[i:]
    for c in [chr(i) for i in range(97,97+26)]:
        tmp += (c in x) and (c in y)
    res = max(res,tmp)
print(res)

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

Solution (Python):
import sys


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

ans = 0
for i in range(1, N):
	max_len = 0
	for asc in range(ord("a"), ord("z")+1):
		flag = False
		for j in range(i):
			if ord(S[j]) == asc:
				for k in range(i,N):
					if ord(S[k]) == asc:
						flag = True
						break
		if not(flag):
			continue
		max_len += 1
		
	ans = max(max_len, ans)
print(ans)

Solution (Python):
n = int(input())
s = str(input())
ans_max = 0
for i in range(n):
    ans = 0
    s1 = s[0:i]
    s2 = s[i:n]
    for k in range(i):
        if s1[k] in s2:
             s1 = s1.replace(s1[k]," ")
             ans += 1
    if ans_max < ans:
        ans_max = ans
print(ans_max)

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

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

for i in range(1, N):
    tmp_ans = len(set(S[0:i]) & set(S[i:]))
    if(tmp_ans > ans):
        ans = tmp_ans

print(ans)

Solution (Python):

n = int(input())
alpha = dict.fromkeys(list("abcdefghijklmnopqrstuvwxyz"),0)
string = input()
for i in range(n):
    alpha[string[i]] += 1

keys = list(alpha.keys())
for key in keys:
    if alpha[key] == 0:
        del alpha[key]
Q = []
maxv = 0
for i in range(n):
    if string[i] not in Q:
        Q.append(string[i])
    alpha[string[i]] -= 1
    if alpha[string[i]] == 0:
        del alpha[string[i]]
    keys = list(alpha.keys())
    cnt = 0
    for ch in Q:
        if ch in keys:
            cnt += 1
    maxv = max(maxv, cnt)

print(maxv)

Solution (Python):

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

Max_count = 0

for i in range(1, N):
  temporary_count = len(set(S[i:]) & set(S[:i]))
  if temporary_count > Max_count:
    Max_count = temporary_count
    
print(Max_count)

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

max_same_count = 0
for i in range(1, n):
	same_count = len(set(s[:i]) & set(s[i:]))
	if max_same_count < same_count:
		max_same_count = same_count

print(max_same_count)

Solution (Python):


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

a = []

for i in range(1, N):
    f1 = set(S[0:i])
    f2 = set(S[i:N])
    a.append(len(f1 & f2))

print(max(a))

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

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

Solution (Python):

N=int(input())
S=input()
a=[]
for i in range(N):
    a.append(set(S[0:i])&set(S[i:N]))
b=[]
for j in range(N):
    b.append(len(a[j]))
print(max(b))

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

res=0
for i in range(N-1):
    SL = list(set(S[:(i+1)]))
    SR = list(set(S[(i+1):]))
    cnt = 0 
    for s1 in SL:
        for s2 in SR:
            if s1==s2 : cnt += 1
    res = max(res,cnt)
print(res)

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


N = int(raw_input())
S = str(raw_input())

counter = 0
ans = 0

for i in range(N):
	X = list(S[:i])
	Y = (S[i:])

	sorted(X)
	sorted(Y)

	X = list(set(X))
	Y = list(set(Y))

	for j in range(len(X)):
		if(str(Y).find(X[j]) != -1):
			counter += 1
	if(counter > ans):
		ans = counter
	counter = 0

print ans

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

Solution (Python):
from collections import Counter

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

res = 0 
for i in range(n):
    temp = 0 
    c1 = Counter(s[:i])
    c2 = Counter(s[i:])
    for c in c1.keys():
        if c in c2.keys():
            temp += 1
    if temp > res:
        res = temp
print(res)

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

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

for i in range(1,N):
    x=set(S[:i-1:])
    y=set(S[i-1::])
    a.append(len(list(x&y)))
    
print(max(a))

Solution (Python):


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

    str_list = list(set(S))
    max_cnt = 0
    
    for i in range(1, N):
        cnt = 0
        first_str = S[:i]
        last_str = S[i:]

        for j in str_list:
            if j in first_str and j in last_str:
                cnt += 1
        if cnt > max_cnt:
            max_cnt = cnt
    
    print(max_cnt)

if __name__ == '__main__':
    main()

Solution (Python):
import sys
import math
import collections
import itertools
import array
import inspect


sys.setrecursionlimit(10000)


def chkprint(*args):
    names = {id(v):k for k,v in inspect.currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))


def to_bin(x):
    return bin(x)[2:]



dp = None

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

    ans = 0

    div = 1
    while div < len(S) - 1:
        front, rear = set(list(S[:div])), set(list(S[div:]))
        kind = len(front & rear)

        ans = max(ans, kind)

        div += 1

    print(ans)

main()

Solution (Python):
N = int(input())
S = input()
output=[]
for i in range(1, N):
	L = list(S[0:i])
	R = list(S[i:N])
	temp=[]
	for j in L:
		if j in R and not j in temp:
			temp.append(j)
	output.append(len(temp))
print(max(output))

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

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

print(max)

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


max = 0
for i in range(1,n):
    xs = set(s[:i])
    ys = set(s[i:])
    l = len(xs&ys)
    if l > max:
        max = l

print(max)

Solution (Python):

N=int(input())
s=list(input())
a = []

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

print(max(a))

Solution (Python):
N = int(input())
*S, = list(input())
A = [chr(i) for i in range(97, 97+26)]
K = 0
for L in range(1,N):
    cnt = 0
    for alpha in A:
        if alpha in S[:L] and alpha in S[L:]:
            cnt += 1
    K = max(K,cnt)
print(K)

Solution (Python):
N = int(input())
S = input()
abc = 'abcdefghijklmnopqrstuvwxyz'

ans = 0
for i in range(1,N):
    left = S[:i]
    righ = S[i:]
    tmp = 0
    for ch in abc:
        if ch in left and ch in righ:
            tmp += 1
    if tmp > ans:
        ans = tmp

print(ans)

Solution (Python):
n = int(raw_input())
s = raw_input()
same = 0
for i in range(1, n-1):
  left = set(s[:i])
  right = set(s[i:])
  union = left & right
  if len(union) > same:
    same = len(union)
print(same)

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

results = []
for i in range(n):
    cnt = 0
    for v in setn:
        if v in s[:i] and v in s[i:]:
            cnt += 1
    results.append(cnt)
print(max(results))

Solution (Python):
n = int(input())
st = input()
b = 0
for i in range(n):
    k = list(set(st[:i]))
    u = 0
    for j in range(len(k)):
        if k[j] in st[i:]:
            u += 1
    if u > b:
        b = u
print(str(b))

Solution (Python):
N=int(input())
S=input()
count_max=0
for i in range(1,N):
    X=S[:i]
    Y=S[i:]
    count=0
    character_in_X=[]
    for character in X:
        if character not in character_in_X:
            character_in_X.append(character)
    for character in character_in_X:
        if character in Y:
            count+=1
    count_max=max(count, count_max)
print(count_max)

Solution (Python):


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

ans = 0
for i in range(1, N):

    str1 = S[:i]
    str2 = S[i:]
    list1 = list(set(str1))
    list2 = list(set(str2))

    tmp = 0
    for s in list1:
        if s in list2:
            tmp += 1
    ans = max(ans, tmp)

print(ans)

Solution (Python):
input()
s = input()
r = 0
for i in range(1,len(s)-1):
  r = max(r, len([k for k in list(set(s[:i])) if k in s[i:]]))
print(r)

Solution (Python):
def same_count(str_list):
    standard_str = min(str_list, key=lambda x: len(x))
    return [all([c in str_ for str_ in str_list]) for c in set(standard_str)].count(True)

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

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

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

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

print(ans)

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

j=0
for i in range(n-1):
	k=set([s[m] for m in range(i+1)])&set([s[n-1-m] for m in range(n-i-1)])
	if j<len(k):
		j=len(k)
print(j)

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

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

amax = 0
for i in range(1, N):
    count = 0
    for s in set(S[:i]):
        if s in S[i:]:
            count += 1
    amax = max(amax, count)
print(amax)

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

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

print(n)

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

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

Solution (Python):
def solve(ls, rs, ans):
    if len(rs) == 0:
        return ans
    ans = max(ans, len(set(ls).intersection(set(rs))))
    return solve(ls + [rs[0]], rs[1:], ans)

if __name__ == "__main__":
    n = int(input())
    s = input()
    print(solve([], s, 0))

Solution (Python):
input()
str=input()
r=[]

for i in range(1,len(str)):
  s1=set(str[0:i])
  s2=set(str[i:])
  r.append(len(s1&s2))

print(max(r))

Solution (Python):
N = int(input())
S = list(input()) 
result_list = [] 
for i in range(N): 
    X = S[:i] 
    Y = S[i:] 
    counter = 0 
    old_list = [] 
    for j in X: 
        if j in Y and not(j in old_list): 
            counter += 1 
            old_list.append(j) 
            result_list.append(counter) 
if result_list == []:
    print(0)
else:
    print (max(result_list))

Solution (Python):
n = int(input())
s = list(input())
Count = 0
for i in range(n):
    f = list(set(s[:(i+1)]))
    r = list(set(s[(i+1):]))
    count = 0
    for j in range(len(f)):
        for k in range(len(r)):
            if f[j] == r[k]:
                count += 1
    if Count < count:
        Count = count
print(Count)

Solution (Python):
N=int(input())
S=input()
count_M=0
for i in range(N):
	SR=S[(i+1):]
	SL=S[:(i+1)]
	count = 0
	for j in range(len(SL)):
		for k in range(len(SR)):
			if(SL[j] == SR[k]):
				count+=1
				SR=SR.replace(SR[k],' ')
	
	if(count_M < count):
		count_M=count

print(count_M)

Solution (Python):
n=int(input())
s=input()
x=[]
y=list(s)
k=0
for i in range(n):
    x.append(s[i])
    del y[0]
    xn=list(set(x))
    yn=list(set(y))
    t=0
    for a in xn:
        for b in yn:
            if a==b:
                t+=1
                k=max(k,t)
print(k)

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

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

count = 0

for n in range(N):
    x = 0
    Sl = S[:n]
    Sr = S[n:]
    for a in set(S):
        if a in Sl and a in Sr:
            x += 1
    if count < x:
        count = x

print(count)

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

Solution (Python):
N = int(input())
S = input()
max_found = 0
for i in range(1,N):
    found = 0
    s1 = S[:i]
    s2 = S[i:]
    for s in set(s1):
        if s in s2:
            found += 1
    if max_found < found:
        max_found = found
print(max_found)

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

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

    res = 0
    for i in range(N):
        sub1 = set(S[:i])
        sub2 = set(S[i:])

        if len(sub1 & sub2) > res:
            res = len(sub1 & sub2)

    print(res)

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

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

common = 0
for i in range(1,len(s)+1):
    common = max(common, len(set(s[:i]).intersection(set(s[i:]))))

print(common)

Solution (Python):
N = int(input())
S = [x for x in input()]
ans = 0





for i in range(1,N+1):
    SL,SR = S[:i],S[i:]
    count = 0
 
    while SL != [] and SR != []:
        if SL[0] in SR:
            count += 1
            a = SL[0]
            while a in SL and a in SR:
                SL.remove(a)
                SR.remove(a)
 
        elif SL[0] not in SR:
            a = SL[0]
            while a in SL:
                SL.remove(a)



    if count >= ans:
        ans = count


print(ans)

Solution (Python):
N = int(input())
S = [x[:1] for x in input()]
ans = 0





for i in range(1,N+1):
    SL,SR = S[:i],S[i:]
    count = 0
 
    while SL != [] and SR != []:
        if SL[0] in SR:
            count += 1
            a = SL[0]
            while a in SL and a in SR:
                SL.remove(a)
                SR.remove(a)
 
        elif SL[0] not in SR:
            a = SL[0]
            while a in SL:
                SL.remove(a)



    if count >= ans:
        ans = count


print(ans)

Solution (Python):
N = int(input())
text = input()
result = []
for i in range(N-1):
      counter = 0
      text1 = text[0:i+1]
      text2 = text[i+1:]
      if  "a" in text1:
            if "a" in text2:
                  counter = counter + 1
      if  "b" in text1:
            if "b" in text2:
                  counter = counter + 1
      if  "c" in text1:
            if "c" in text2:
                  counter = counter + 1
      if  "d" in text1:
            if "d" in text2:
                  counter = counter + 1
      if  "e" in text1:
            if "e" in text2:
                  counter = counter + 1
      if  "f" in text1:
            if "f" in text2:
                  counter = counter + 1
      if  "g" in text1:
            if "g" in text2:
                  counter = counter + 1
      if  "h" in text1:
            if "h" in text2:
                  counter = counter + 1
      if  "i" in text1:
            if "i" in text2:
                  counter = counter + 1
      if  "j" in text1:
            if "j" in text2:
                  counter = counter + 1
      if  "k" in text1:
            if "k" in text2:
                  counter = counter + 1
      if  "l" in text1:
            if "l" in text2:
                  counter = counter + 1
      if  "m" in text1:
            if "m" in text2:
                  counter = counter + 1
      if  "n" in text1:
            if "n" in text2:
                  counter = counter + 1
      if  "o" in text1:
            if "o" in text2:
                  counter = counter + 1
      if  "p" in text1:
            if "p" in text2:
                  counter = counter + 1
      if  "q" in text1:
            if "q" in text2:
                  counter = counter + 1
      if  "r" in text1:
            if "r" in text2:
                  counter = counter + 1
      if  "s" in text1:
            if "s" in text2:
                  counter = counter + 1
      if  "t" in text1:
            if "t" in text2:
                  counter = counter + 1
      if  "u" in text1:
            if "u" in text2:
                  counter = counter + 1
      if  "v" in text1:
            if "v" in text2:
                  counter = counter + 1
      if  "w" in text1:
            if "w" in text2:
                  counter = counter + 1
      if  "x" in text1:
            if "x" in text2:
                  counter = counter + 1
      if  "y" in text1:
            if "y" in text2:
                  counter = counter + 1
      if  "z" in text1:
            if "z" in text2:
                      counter = counter + 1
      result = result + [counter]

print(max(result))

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

Solution (Python):
from collections import Counter
alphabet='abcdefghijklmnopqrstuvwxyz'

N=int(raw_input())
S=raw_input()

st2 = Counter(S)
st1 = Counter()
best = 0
for i in range(N-1):
  st1.update(S[i])
  cnt = 0
  for k,v in st1.items():
    if st2[k] - v > 0:
      cnt += 1
  best = max(best, cnt)
print best

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

def count_common(a, b):
    min_char = set(min(a, b))
    max_char = set(max(a, b))
    return len(max_char) - len(max_char - min_char)

rtn = 0
for i in range(N):
    a = S[:i]
    b = S[i:]
    tmp = count_common(a, b)
    if rtn < tmp:
        rtn = tmp

print(rtn)

Solution (Python):
N = int(input())
S = str(input())
sets = [(set(S[:i+1]),set(S[i+1:])) for i in range(len(S)-1)]
size_of_intersection = [len(s1.intersection(s2)) for s1, s2 in sets]
if size_of_intersection:
    print(max(size_of_intersection))
else:
    print(0)

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

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