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 = list(input())
half = int(n/2)

max1 = 0
for i in range(half):
  f = set(s[:half-i])
  b = set(s[half-i:])
  union = len(f&b)
  if max1 < union:
    max1 = union
  
    

max2 = 0
for i in range(half):
  f = set(s[:half+i])
  b = set(s[half+i:])
  union = len(f&b)
  if max2 < union:
    max2 = union
  
    
    
ans = max1 if max1>max2 else max2
print(ans)

Solution (Python):

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

ans = 0

for i in range(N-1):
    L = S[:i+1]
    R = S[i+1:]
    c = 0
    for l in set(L):
        if l in R:
            c += 1

    ans = max(ans, c)

print(ans)

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

for i in range(1, N):
  res.append(len(set(S[:i]) & set(S[i:])))

print(max(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 = input()
ans = 0
for i in range(1, N - 1):
    ans = max(ans, len(set(S[:i]) & set(S[i:])))
print(ans)

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

for i in range(1,n):
    l = list(s[0:i])
    r = list(s[i:n])
    dup = len(set(l)&set(r))

    if ans < dup:
        ans = dup
print(ans)

Solution (Python):
import sys

input = sys.stdin.buffer.readline
in_n = lambda: int(input())
in_nn = lambda: map(int, input().split())
in_s = lambda: input().rstrip().decode('utf-8')
in_map = lambda: [s == ord('.') for s in input() if s != ord('\n')]

MOD = 10**9 + 7
INF = 8 * 10**18


def main():

    N = in_n()
    S = in_s()

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

    print(ans)


if __name__ == '__main__':
    main()

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

for i in range(n-1):
    left.add(s[i])
    right=set()
    for j in range(i+1,n):
        right.add(s[j])
    cnt=0
    for ll in left:
        if ll in right:
            cnt+=1
    ans=max(ans,cnt)

print(ans)

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

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

Solution (Python):
import sys

input = sys.stdin.readline
N = int(input())
S = list(input().strip())

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()
tmp,ans=0,0
for i in range(n+1):
    s0=[]
    for j in range(n):
        if j<i:
            t=True
            for x in s0:
                if x==s[j]:t=False
            if t:s0.append(s[j])
        else:
            for k in range(len(s0)):
                if s0[k]==s[j]:
                    tmp+=1
                    s0[k]=-1
    
    tmp,ans=0,max(ans,tmp)
print(ans)

Solution (Python):
n = int(input())
s = input()
count = 0
ans = 0
for i in range(0, n - 1):
    x = list(s[:i + 1])
    y = list(s[i + 1:])
    for c in range(ord('a'), ord('z') + 1):
        if chr(c) in x and chr(c) in y:
            count += 1
    if ans < count:
        ans = count
    count = 0
print(ans)

Solution (Python):
n=int(input())
s=input()
a=list("abcdefghijklmnopqrstuvwxyz")
x=[]
y=[]
m=0
for i in range(n-1):
    x=[s[j] for j in range(i)]
    y=[s[j] for j in range(i,n)]
    ans=0
    for j in range(26):
        if a[j] in x and a[j] in y:
            ans+=1
    m=max(ans,m)
print(m)

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"]
ans = 0
for i in range(1,n-1):
    x = s[:i]
    y = s[i:]
    comp = 0
    for j in alphabet:
        if j in x and j in y:
            comp += 1
    if comp > ans:
        ans = comp
print(ans)

Solution (Python):
from collections import Counter
N = int(input())
S = input()
ans = 0
for i in range(N):
    d1 = Counter(S[:i])
    d2 = Counter(S[i:])
    tmp = 0
    for alphabet in 'abcdefghijklmnopqrstuvwxyz':
        tmp += min(d1[alphabet], d2[alphabet], 1)
    print
    ans = max(ans, tmp)
print(ans)

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

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

cnt = 0
for i in range(1, n-1):
    tmp = 0
    r, l = s[:i], s[i:]
    rs = list(set(r))
    for ri in rs:
        if l.count(ri) > 0:
            tmp += 1
    cnt = max(cnt, tmp)

print(cnt)

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

alps = 'abcdefghijklmnopqrstuvwxyz'
ans = 0
for i in range(1,n):
    s1 = s[:i]
    s2 = s[i:]
    cnt = 0
    for alp in alps:
        if alp in s1 and alp in s2:
            cnt += 1
    ans = max(ans,cnt)

print(ans)

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
s = input()
res = 0
for i in range(n):
    a = s[:i]
    b = s[i:]
    ss = set(b)
    ans = 0
    sss = set()
    for x in a:
        if x in ss and not x in sss:
            ans += 1
        sss.add(x)
    res = max(res, ans)
print(res)

Solution (Python):
n = int(input())
s = list(input())
ans = []
for i in range(1, n):
    first_falf = set(s[:i])
    after_falf = set(s[i:])
    count = 0
    for word in first_falf:
        if word in after_falf:
            count += 1
    ans.append(count)
print(max(ans))

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

def count(x, y):
   l= []
   result = 0
   for i in range(len(x + y)):
      l.append((x + y)[i])
   for letter in set(l):
      if (letter in x) and (letter in y):
         result += 1
   return result

lst = []
for i in range(1, N):
   lst.append(count(s[:i], s[i:]))

print(max(lst))

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

for i in range(1,n):
    s1 = s[:i]
    s2 = s[i:]
    S1 = list(set(s1))
    cnt = 0
    for j in range(len(S1)):
        if S1[j] in s2:
            cnt += 1
            ans = max(ans, cnt)
            
print(ans)

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

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

    print(ans)


main()

Solution (Python):
def answer(n: int, s: str) -> int:
    result = 0
    for i in range(1, n):
        x = set(s[i:])
        y = set(s[:i])
        common_characters = x.intersection(y)
        result = max(result, len(common_characters))

    return result

def main():
    n = int(input())
    s = input()
    print(answer(n,s))

if __name__ == '__main__':
    main()

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

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

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

Solution (Python):
n=int(input())
s = list(input())
wd = list("abcdefghijklmnopqrstuvwxyz")
ans=0
for i in range(n):
  s1 = set(s[:i])
  s2=set(s[i:])
  tmp=0
  for w in wd:
    if w in s1 and w in s2:
      tmp+=1
  ans=max(ans,tmp)
print(ans)

Solution (Python):



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


def check(i):
    return len(set(S[:i]) & set(S[i:]))


ans = [0] * N
for i in range(N):
    ans[i] = check(i)

print(max(ans))

Solution (Python):
N = int(input())
N_List = list(map(str,input().strip()))
ans = 0
for i in range(1,N):
    c_ans = len(set(N_List[:i]) & set(N_List[i:]))
    if c_ans > ans:
        ans = c_ans
print(ans)

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

ans = 0

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

print(ans)

Solution (Python):
def calc_intersection():
    n = int(input())
    s = input()
    list_intersection = []

    for i in range(1, n):
        a = set(s[:i])
        b = set(s[i:])
        intersection_a_b = a.intersection(b)
        list_intersection.append(len(intersection_a_b))
    return max(list_intersection)


if __name__ == '__main__':
    print(calc_intersection())

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

for i in range(1, n + 1):
    a = set(s[:i])
    b = set(s[i:])
    intersection_a_b = a.intersection(b)
    list_intersection.append(len(intersection_a_b))

print(max(list_intersection))

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

table = [0] * (len(S)+1)
wordDict = {}

for i in range(len(S)):
  if S[i] in wordDict :
    wordDict[S[i]] = [wordDict[S[i]][0], i]
  else:
    wordDict[S[i]] = [i+1, i]

for ran in wordDict.values():
  if ran[0] > ran[1]:
    continue
  for i in range(ran[0], ran[1]+1):
    table[i] += 1

maxNum = 0
for i in range(len(S)+1):
  maxNum = max(maxNum, table[i])

print(maxNum)

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

def check(a,b):
  c = [0] * 26
  d = [0] * 26
  for i in range(len(a)):
    c[ord(a[i])-97] = 1
  for i in range(len(b)):
    d[ord(b[i])-97] = 1
  ans = 0
  for i in range(26):
    if c[i] == 1 and d[i] == 1:
      ans += 1
  return ans

res = 0
for i in range(n):
  res = max(res,check(s[:i],s[i:]))
print(res)

Solution (Python):
def al_cnt(k,s):
    count = 0
    if 'a' in s[:k] and 'a' in s[k:]:
        count += 1
    if 'b' in s[:k] and 'b' in s[k:]:
        count += 1
    if 'c' in s[:k] and 'c' in s[k:]:
        count += 1
    if 'd' in s[:k] and 'd' in s[k:]:
        count += 1
    if 'e' in s[:k] and 'e' in s[k:]:
        count += 1
    if 'f' in s[:k] and'f' in s[k:]:
        count += 1
    if 'g' in s[:k] and 'g' in s[k:]:
        count += 1
    if 'h' in s[:k] and 'h' in s[k:]:
        count += 1
    if 'i' in s[:k] and 'i' in s[k:]:
        count += 1
    if 'j' in s[:k] and 'j' in s[k:]:
        count += 1
    if 'k' in s[:k] and 'k' in s[k:]:
        count += 1
    if 'l' in s[:k] and 'l' in s[k:]:
        count += 1
    if 'm' in s[:k] and 'm' in s[k:]:
        count += 1
    if 'n' in s[:k] and 'n' in s[k:]:
        count += 1
    if 'o' in s[:k] and 'o' in s[k:]:
        count += 1
    if 'p' in s[:k] and 'p' in s[k:]:
        count += 1
    if 'q' in s[:k] and 'q' in s[k:]:
        count += 1
    if 'r' in s[:k] and 'r' in s[k:]:
        count += 1
    if 's' in s[:k] and 's' in s[k:]:
        count += 1
    if 't' in s[:k] and 't' in s[k:]:
        count += 1
    if 'u' in s[:k] and 'u' in s[k:]:
        count += 1
    if 'v' in s[:k] and 'v' in s[k:]:
        count += 1
    if 'w' in s[:k] and 'w' in s[k:]:
        count += 1
    if 'x' in s[:k] and 'x' in s[k:]:
        count += 1
    if 'y' in s[:k] and 'y' in s[k:]:
        count += 1
    if 'z' in s[:k] and 'z' in s[k:]:
        count += 1
    return count
n = int(input())
s = input()
ans = 0
for i in range(1,n-1):
    temp = al_cnt(i,s)
    ans = max(ans,temp)
print(ans)

Solution (Python):
n = int(input())
s = input()
ans = 0
for i in range(n-1):
    s1 = s[:i+1]
    it = iter(s[i+1:])
    it2 = iter(s[i+1:])
    s2 = dict(zip(it,it2))
    visited = {}
    for i in s1:
        if i in visited:
            continue
        if i in s2:
            visited[i] = 1
    ans = max(ans,len(visited))
print(ans)

Solution (Python):
n=int(input())
s=input()
alh="abcdefghijklmnopqrstuvwxyz"
max=0
for i in range(n):
  front=s[:i]
  rear=s[i:]
  cnt=0
  for j in alh:
    if j in front and j in rear:
      cnt+=1
  if cnt>max:
    max=cnt
print(max)

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n = int(input())
s = input().strip()

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

Solution (Python):
n=int(input())
s=input()
shurui=[]
for i in range(len(s)-1):
  zenhan=s[0:i+1]
  kouhan=s[i+1:len(s)]
  kaburu=[]
  kaburu.clear()
  a=0
  for j in range(len(zenhan)):
    if kouhan.count(zenhan[j]) != 0 and kaburu.count(zenhan[j])==0:
      a+=1
      kaburu.append(zenhan[j])
  shurui.append(a)
print(max(shurui))

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

res = 0

for i in range(1, N):
    cnt = set(S[0:i]) & set(S[i:N])
    if res < len(cnt):
        res = len(cnt)

print(res)

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

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

cnt = []
for n in range(1, N):
    x = sorted(S[:n])
    y = sorted(S[n:])
    cnt.append(len(set(x)&set(y)))
        
print(max(cnt))

Solution (Python):
n = int(input())
s = input()
cnt = 0
for i in range(1,n):
    l = []
    for j in s[:i]:
        if j in s[i:]:
            l.append(j)
    l = set(l)
    cnt = max(cnt,len(l))

print(cnt)

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

for i in range(1,len(s)):
  s1 = s[:i]
  s2 = s[i:]
  cnt = set()
  for j in s1:
    if j in s2:
      cnt.add(j)
  ans = max(ans,len(cnt))
print(ans)

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

x=[]

for i in range(n):
    a=s[:i]
    b=s[i:]
    cnt=0
    c=set(a)
    d=set(b)
    c=list(c)
    d=list(d)
    for j in range(len(c)):
        for k in range(len(d)):
            if c[j]==d[k]:
                cnt+=1
                break
    x.append(cnt)

print(max(x))

Solution (Python):
n=int(input())
S=input()
ans=0
for i in range(1,len(S)):
  S1=S[:i]
  S2=S[i:]
  cnt = set()
  for s1 in S1:
    if s1 in S2:
      cnt.add(s1)
  ans = max(ans,len(cnt))
print(ans)

Solution (Python):
def main():
    input()
    s = input()
    ans = []
    for i in range(1, len(s)):
        left = set(s[:i])
        right = set(s[i:])
        ans.append(len(left & right))
    print(max(ans))


if __name__ == '__main__':
    main()

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

for i in range(N-1):
    S1=list(S[0:i+1])
    S2=list(S[i+1:N])

    temp=0
    li1=[0]*26
    li2=[0]*26

    for j in range(len(S1)):
        li1[alf.find(S1[j])]+=1
    for k in range(len(S2)):
        li2[alf.find(S2[k])]+=1
    
    for l in range(26):
        if min(li1[l],li2[l])!=0:
            temp+=1
    if temp>ans:
        ans=temp
print(ans)

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

max_cnt = 0
for i in range(1, N):
    x = set(S[0:i])
    y = set(S[i:N])
    x_y = len(x & y)
    
    if x_y > max_cnt:
        max_cnt = x_y
        
print(max_cnt)

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

max_count = 0
for i in range(0, N-1):
  X = S[0:i+1]
  Y = S[i+1:]

  X_set = set(X)
  Y_set = set(Y)

  count = len(X_set & Y_set)
  if max_count < count:
    max_count = count

print(max_count)

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

ss = []
for s in S:
    if s not in ss:
        ss.append(s)

max_count = 0
for i in range(1, N-1):
    count = 0
    for s in ss:
        x = S[0:i]
        y = S[i:N]
        if s in x and s in y:
            count += 1
    if count > max_count:
        max_count = count

print(max_count)

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

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

print(max_counter)

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

for i in range(1,n-1):
  L = S[:i]
  R = S[i:]
  UL = set(L)
  UR = set(R)
  ans = max(ans, len(UL & UR))

print(ans)

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

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

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

print(r)

Solution (Python):
n = int(input())
s = input()
L = ""
R = ""
C = ""
tmp = 0
ans = []
for i in range(1, len(s)):
    L = s[:i]
    R = s[i:]
    C = len(set(L) & set(R))
    ans.append(C)
    L = ""
    R = ""
print(max(ans))

Solution (Python):
import sys
lines = [s.rstrip("\n") for s in sys.stdin.readlines()]
n, = [int(num) for num in lines.pop(0).split(" ")]
s = lines.pop(0)

ans = 0
for i in range(n):
    intersection = set(s[:i]) & set(s[i:])
    num = len(intersection)
    if num > ans:
        ans = num
print(ans)

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

for i in range(1, N+1):
    ans = 0
    A = []
    B = []
    A = list(set(S[:i]))
    B = list(set(S[i:]))
    for a in A:
        for b in B:
            if a == b:
                ans += 1
    ANS.append(ans)
print(max(ANS))

Solution (Python):
N=int(input())
S=input()
ans=0
s="abcdefghijklmnopqrstuvwxyz"
for i in range(1,N):
    T1=S[0:i]
    T2=S[i:N]
    count=0
    for c in s:
        if c in T1 and c in T2:
            count+=1
    ans=max(ans,count)
print(ans)

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

max_count = 0

for i in range(1, n):
    s1 = ''.join(set(s[:i]))
    s2 = ''.join(set(s[i:]))
    count = 0
    for j in range(len(s1)):
        if s1[j] in s2:
            count += 1
    if count > max_count:
        max_count = count
print(max_count)

Solution (Python):
import sys



def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    n = input_int()
    S = input()
    ans = 0
    for i in range(1, n):
        x = set(S[:i])
        y = set(S[i:])
        cnt = 0
        for c in x:
            if c in y:
                cnt += 1
        ans = max(cnt, ans)
    print(ans)

    return


if __name__ == "__main__":
    main()

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

res = 0
for i in range(1,N):
    com = set(S[:i]) & set(S[i:])
    if res<len(com):
        res=len(com)
print(res)

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

def f(s, t):
  set_s = set()
  set_t = set()
  for i in s:
    set_s.add(i)
  for i in t:
    set_t.add(i)
  return len( set_s & set_t )

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

Solution (Python):
N = int(input())
S = input()
list = [0]*N
for i in range(N):
    A = S[:i]
    B = S[i:]
    A = set(A)
    B = set(B)
    for j in A:
      if j in B:
        list[i] += 1
list = sorted(list)
print(list[-1])

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

al = "abcdefghijklmnopqrstuwvxyz"

_max = 0
for i in range(1, N-1):
    s_1 = S[:i]
    s_2 = S[i:]
    count = 0
    for a in al:
        if a in s_1 and a in s_2:
            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()
C = [chr(i) for i in range(97, 123)]
ans = 0
for i in range(0, N - 1):
  count = 0
  a = S[:i + 1]
  b = S[i + 1:]
  for c in C:
    if c in a and c in b:
      count += 1
  ans = max(count, ans)
print(ans)

Solution (Python):
n = int(input())
s = input()
alphabets = 'abcdefghijklmnopqrstuvwxyz'
max_chr = 0

for i in range(len(s)-1):
    cnt = 0
    for letter in alphabets:
        if (letter in s[:i+1]) and (letter in s[i+1:]):
            cnt += 1
    max_chr = max(max_chr, cnt)
print(max_chr)

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

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

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

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

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

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

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

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

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

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

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

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

Solution (Python):
n=int(input())
s=input()
count = 0
for i in range(n-1):
  a=s[:i + 1]
  b=s[i+1:]
  temp = 0
  for j in range(27):
    if chr(96+j) in a and chr(96+j) in b:
      temp += 1
  count = max(temp, count)
print(count)

Solution (Python):
n = int(input())
a = input()
dic="abcdefghijklmnopqrstuvwxyz"
maxcount = 0
for i in range(n):
  count = 0
  for j in range(26):
    if str(dic[j]) in a[:i] and str(dic[j]) in a[i:]:
      count+=1
  maxcount = max(count,maxcount)
print(maxcount)

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

ans = 0
for i in range(1,N-1):
  set1 = set(S[:i])
  set2 = set(S[i:])
  z = set1.intersection(set2)
  ans = max(ans,len(z))

print(ans)

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

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

Solution (Python):
from string import ascii_lowercase


def cut_and_count(s, n, i):
    x = set(s[:i])
    y = set(s[i:])
    cnt = 0

    for ch in ascii_lowercase:
        if ch in x and ch in y:
            cnt += 1
    return cnt


def main():
    n = int(input())
    s = list(input())
    ans = 0

    for i in range(1, n):
        res = cut_and_count(s, n, i)
        ans = max(ans, res)

    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
import sys
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right 
from heapq import heapify, heappop, heappush

sys.setrecursionlimit(10**6)
INF = 10**20

def mint():
    return map(int,input().split())
def lint():
    return map(int,input().split())
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])

N = int(input())
S = input()
X = [0]*26
Y = [0]*26

for i in range(N):
    k = ord(S[i])-ord('a')
    Y[k] += 1

ans = 0
for i in range(N):
    k = ord(S[i])-ord('a')
    X[k] += 1
    Y[k] -= 1
    tmp = 0
    for j in range(26):
        if X[j]>0 and Y[j]>0:
            tmp += 1
    ans = max(ans,tmp)
print(ans)

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

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


l1 = [0] * (n-1)
now = [False] * 26
for i in range(n-1):
    now[ord(s[i]) - 97] = True
    l1[i] = now.copy()


l2 = [0] * (n-1)
now = [False] * 26
for i in range(n-1, 0, -1):
    now[ord(s[i]) - 97] = True
    l2[i-1] = now.copy()

ans = 0
for i in range(n-1):
    cnt = 0
    for j in range(26):
        if l1[i][j] and l2[i][j]:
            cnt += 1

    if ans < cnt:
        ans = cnt

print(ans)

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

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


l1 = [0] * (n-1)
now = [False] * 26
for i in range(n-1):
    now[ord(s[i]) - 97] = True
    l1[i] = now.copy()


l2 = [0] * (n-1)
now = [False] * 26
for i in range(n-1, 0, -1):
    now[ord(s[i]) - 97] = True
    l2[i-1] = now.copy()

ans = 0
for i in range(n-1):
    cnt = 0
    for j in range(26):
        if l1[i][j] and l2[i][j]:
            cnt += 1

    if ans < cnt:
        ans = cnt

print(ans)

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

list1 =  []
for i in range(N):
  x = set()
  
  for s in S[:i+1]:
    if s in S[i+1:]:
      x.add(s)
  list1.append(len(x))
print(max(list1))

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

Solution (Python):
n = int(input())
s = input()
ans = 0
for i in range(1, n+1):
    cnt = 0
    x = s[0:i]
    y = s[i:n+1]
    for j in range(97, 123):
        if chr(j) in x and chr(j) in y:
            cnt += 1
    ans = max(cnt, ans)
print(ans)

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

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

Solution (Python):
n=int(input())
s=input()
data=[]
ans=0
for i in range(n-1):
  if s[i] not in data:
    data.append(s[i])
  res=0
  for j in data:
    if j in s[i+1:n]:
      res+=1
  ans=max(ans,res)
print(ans)

Solution (Python):


N = int(input())
S = input()
ans = 0
for i in range(len(S)):
    left = set(S[0:i])
    right = set(S[i:len(S)])

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

Solution (Python):
N = int(input())
S = list(input())
dic = {}

for i in range(N):
  if S[i] not in dic.keys():
    dic[S[i]] = [i]
  else:
    dic[S[i]].append(i)
    
ans = 0
for j in range(1,N):
  cnt = 0
  for k in dic.values():
    check1 = False
    check2 = False
    for l in k:
      if l < j:
        check1 = True
      if j <= l:
        check2 = True
    if check1 and check2:
      cnt += 1
  ans = max(ans, cnt)
  
print(ans)

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

ans = 0
for i in range(N):
	s1,s2=set(S[:i]),set(S[i:])
	tmp = len(s1.intersection(s2))
	if tmp > ans:ans=tmp


print(ans)

Solution (Python):
N = int(input())
S = input()
ma=0
for i in range(1,N):
    leftS = S[0:i]
    rightS = S[i:]
    setLeftS = set(leftS)
    setRightS = set(rightS)
    m = 0
    for r in setRightS:
        if r in setLeftS:
            m+=1
    ma = max(ma,m)
print(ma)

Solution (Python):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N = int(readline())
    S = input()
    ans = 0
    for i in range(1, N):
        first = set(S[:i])
        second = set(S[i:])
        score = len(first & second)
        ans = max(ans, score)

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
S = str(input())
_sum = 0
visited = set()
_sum_visited = set()
max_size = len(set(S))


for n in range(N-1):
  if S[n] in S[n+1:] and (S[n] not in visited):
    _sum += 1
  
  elif S[n] in visited and (S[n] not in S[n+1:]):
    _sum -= 1
  
  visited.add(S[n])
  _sum_visited.add(_sum)
  last_size = len(set(S[n+1]))
  ans = max(_sum_visited)
  if ans == max_size:
    break
    
print(max(_sum_visited))

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

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

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

cnt = 0
for i in range(N):
    s1 = set(S[:i])
    s2 = set(S[i:])
    l: int = len(s1 & s2)
    if l > cnt:
        cnt = l

print(cnt)

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

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

Solution (Python):
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]

def main():
    n = i_input()
    s = s_input()
    ans = 0
    for i in range(n):
        l = set(s[:i])
        r = set(s[i:])
        trial = 0
        for k in l:
            if k in r:
                trial += 1
        ans = max(ans,trial)
    print(ans)



if __name__=="__main__":
    main()

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

Solution (Python):
n = int(input())
s = input()
a = []
for i in range(1, len(s)):
    s1 = list(s[:i])
    s2 = list(s[i:])
    b = []
    for j in s1:
        if j in s2 and j not in b:
            b.append(j)
    a.append(len(b))
print(max(a))

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

Solution (Python):
n = int(input())
s = input()
match = []
for i in range(1,len(s)):
    s1 = list(s[:i])
    s2 = list(s[i:])
    cnts = []
    for j in s1:
        if j in s2:
            if j not in cnts:
                cnts.append(j)
    match.append(len(cnts))
print(max(match))

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

Solution (Python):
N=int(input())
S=input()
tmp=0
ans=0
for i in range(N):
    A=set(S[:i])
    B=set(S[i:N])
    AB=A & B
    tmp=len(AB)
    if tmp > ans:
        ans=tmp
print(ans)

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

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

print(ans)

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

Solution (Python):
n = int(input())
s = list(input())
ans = 0
c = 0
fh = []
lh = s
for i in range(n):
  tmp = lh.pop(0)
  if tmp not in fh:
    if tmp in lh:
      c += 1
  elif tmp not in lh:
    c -= 1
  fh.append(tmp)
  ans = max(ans, c)
print(ans)

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

ans = 0

for i in range(1, N + 1):
    a = list(set(S[:i]))
    b = list(set(S[i:]))
    ans_ = sum([b.count(x) for x in a])
    
    ans = max(ans, ans_)

print(ans)

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

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