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):
import collections
n = int(input())
s = input()
ans = 0
for l in range(1,n):
  s1 = s[:l]
  s2 = s[l:]
  s1 = collections.Counter(s1)
  s2 = collections.Counter(s2)
  num = 0
  for i in s1:
    if i in s2:
      num += 1
      ans = max(ans,num)
print(ans)

Solution (Python):

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

mcnt = 0
for i in range(N-1):
    count = 0
    l = S[:i]
    r = S[i:]
    l = set(l)
    r = set(r)
    for j in l:
        if j in r:
            count += 1
    mcnt = max(mcnt,count)
print(mcnt)

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

Solution (Python):
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n = I()
    s = S()
    ans = 0
    
    for i in range(1,n):
        left = s[:i]
        right = s[i:]
        leftset = set(left)
        rightset = set(right)
        share = len(leftset & rightset)
        ans = max(ans, share)

    print(ans)
main()

Solution (Python):
n = int(input())
s = input()
res = 0
for i in range(1, n - 1):
    l = set(s[:i])
    r = set(s[i:])
    tmp = 0
    for j in range(26):
        if chr(ord("a") + j) in l and chr(ord("a") + j) in r:
            tmp += 1
    res = max(res, tmp)
print(res)

Solution (Python):
N = int (input ())
S = input ()
x = 0
for i in range (N-1):
  L = S[:i+1]
  R = S[i+1:]
  X = 0
  for i in range (len(L)):
    if R.count(L[i]) != 0 and L[:i].count(L[i]) == 0:
      X += 1
  if X > x:
    x = X
print (x)

Solution (Python):
n=int(input())
s=list(input())
ma=0
for i in range(n):
  c=[]
  count=0
  a=s[:i+1]
  b=s[i+1:]
  for j in range(len(a)):
    if a[j] not in c:
      if a[j] in b:
        c.append(a[j])
        count+=1
    if count>ma:
      ma=count
print(ma)

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

ans = 0
for i in range(1,n-1):
  t = len(set(s[:i]) & set(s[i:]))
  if ans < t: ans = t
print(ans)

Solution (Python):

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

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

print(ans)

Solution (Python):

import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect
from scipy.special import comb
import copy
sys.setrecursionlimit(10**6)


def zz():
    return list(map(int, sys.stdin.readline().split()))


def z():
    return int(sys.stdin.readline())


def S():
    return sys.stdin.readline()[:-1]


def C(line):
    return [sys.stdin.readline() for _ in range(line)]


N = z()
S = S()
ans = 0
for i in range(N):
    a = collections.Counter(S[:i])
    b = collections.Counter(S[i:])
    ans = max(len(set(a.keys()) & set(b.keys())), ans)
print(ans)

Solution (Python):
N = int(input())
S = input()
ans = 0
a = [0] * 26
for i in range(N):
    a[ord(S[i])-ord('a')] += 1

b = [0] * 26
for i in range(N):
    a[ord(S[i])-ord('a')] -= 1
    b[ord(S[i])-ord('a')] += 1
    cnt = 0
    for j in range(26):
        if a[j]*b[j]>0:
            cnt += 1
    ans = max(ans,cnt)
print(ans)

Solution (Python):
n = int(input())
s = input()
li = []
for i in range(n-1):
    cnt = 0
    for j in set(list(s[:i+1])):
        if j in set(list(s[i+1:])):
            cnt +=1
    li += [cnt]
print(max(li))

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

ans = 0

for i in range(N-1):
    set1 = set(S[:i+1])
    set2 = set(S[i+1:])
    
    ans = max(ans, len(set1&set2))
    
print(ans)

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

ans = 0

for i in range(N-1):
    l1 = [0]*26
    l2 = [0]*26
    for j in S[:i+1]:
        if l1[(ord(j)-ord("a"))]==0:
            l1[(ord(j)-ord("a"))]=1
    for k in S[i+1:]:
        if l2[(ord(k)-ord("a"))]==0:
            l2[(ord(k)-ord("a"))]=1
    cnt = 0
    for i in range(26):
        if l1[i]*l2[i] == 1:
            cnt += 1
    ans = max(ans, cnt)

print(ans)

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

ans_list = []
for i in range(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
    ans_list.append(ans)

a = max(ans_list)
print(a)

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

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

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

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

    tmp = len(set(be)&set(af))
    ans=max(ans,tmp)

print(ans)

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

ans = 0
for i in range(N-1):
    a = [0]*26
    b = [0]*26
    for j in S[0:i+1]:
        if a[ord(j)-ord('a')]==0:
            a[ord(j)-ord('a')]=1
    for j in S[i+1:N]:
        if b[ord(j)-ord('a')]==0:
            b[ord(j)-ord('a')]=1
    subans = 0    
    for i in range(26):
        if a[i]*b[i]==1:
            subans+=1
    ans = max(ans,subans)
    
print(ans)

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

Solution (Python):
n=int(input())
s=list(input())
ans=[]
count=0
num=[]

for i in range(1,n+1):
  l=s[:i]
  r=s[i:]
  
  l=sorted(l)
  r=sorted(r)
  
  for j in l:
    if j in r:
      if j not in num:
        count+=1
        num.append(j)
        
  ans.append(count)
  num.clear()
  count=0
  
print(max(ans))

Solution (Python):
n = int(input())
s = str(input())
m = 0
w = []
for j in s:
    w.append(j)
w = list(set(w))
for i in range(1,n):
    t = 0
    for h in w:
        if 1 <= s[:i].count(h) and 1 <= s[i:].count(h):
            t += 1
    if m < t:
        m = t
print(m)

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

m = 0

for i in range(1, n):
    t = set(s[:i])
    u = set(s[i:])
    m = max(len(t & u), m)

print(m)

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

print(nax)

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

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

Solution (Python):
N=int(input())
S=str(input())
m=0
for i in range(N):
    a=[]
    x=S[:i]
    y=S[i:]
    for j in range(len(x)):
        if x[j] in y:
            if x[j] not in a:
                a.append(x[j])
    if len(a)>m:
        m=len(a)
                
print(m)

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

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


ans = []
for i in range(1, n):
  a = s[0:i]
  b = s[i:n]
  res = []
  for j in a:
    if j in b and j not in res:
      res.append(j)
    ans.append(len(res))
    
print(max(ans))

Solution (Python):


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

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

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

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

Solution (Python):
N = int(input())
S = input()
chars = list("abcdefghijklmnopqrstuvwxyz")
ans_lst = []
for cut in range(1, N):
    left = S[:cut]
    right = S[cut:]
    count = 0
    for char in chars:
        if char in left and char in right:
            count += 1
    ans_lst.append(count)
print(max(ans_lst))

Solution (Python):
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    n = ni()
    S = ns()
    ans = 0
    for i in range(1, n - 1):
        X = S[:i]
        Y = S[i:]
        tmp = len(set(X) & set(Y))
        ans = max(ans, tmp)
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
s = input()
ans = 0
for i in range(n-1):
    c = 0
    for j in range(26):
        if chr(j+97) in s[:i+1] and chr(j+97) in s[i+1:]:
            c += 1
    if c > ans:
        ans = c
print(ans)

Solution (Python):
N = int(input())
S = input()
ans = 0
for i in range(N-1):
    c = 0
    for j in range(26):
        if chr(j+97) in S[:i+1] and chr(j+97) in S[i+1:]:
            c += 1
    if c > ans:
        ans = c
print(ans)

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

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

for i in range(1,n):
    s_1 = set(s[:i])
    s_2 = set(s[i:])
    lis = [len(set(s[:i])&set(s[i:])) for i in range(1,n) ]
print(max(lis))

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

for i in range(1,n):
  count=0
  
  l=set(a[:i])
  g=set(a[i:])
  
  for j in l:
    if j in g: count+=1
  if max < count: max=count
print(max)

Solution (Python):
n = int(input())
s = str(input())
dic = {}
for i in s:
    dic.setdefault(i,0)
    dic[i] += 1

move = {}
ans = []
cnt = 0
for i in s:
    dic[i] -= 1
    move.setdefault(i,0)
    move[i] += 1
    if dic[i]>0 and move[i]>0:
        if i not in ans:
            ans.append(i)
    elif dic[i]==0:
        if i in ans:
            ans.remove(i)
    cnt = max(cnt,len(ans))
print(cnt)

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

result =[]

for i in range(N):
    left = []
    right= []
    for l in range(0,i):
        if S[l] not in left:
            left.append(S[l])
        else:
            continue

    
     
    for r in range(i,N):
        if S[r] not in right:
             right.append(S[r])
        else:
            continue


    count =0
    for i in left:
        for  s in right:
            if i == s :
                count +=1
    result.append(count)
    

print(max(result))

Solution (Python):
N = int(input())
S = list(input())
ans = 0
for i in range(N):
    a = S[:i]
    b = S[i:]
    aset = set(a)
    bset = set(b)
    count = 0
    for i in aset:
        if i in bset:
            count += 1
    ans = max(ans,count)
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:]))
    kaburi = 0
    for j in range(len(X)):
        for k in range(len(Y)):
            if X[j] == Y[k]:
                kaburi += 1
    if kaburi > ans:
        ans = kaburi

print(ans)

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

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

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

ans = 0

for s in S:
    si = ord(s) - 97
    li1[si] += 1

for s in S:
    si = ord(s) - 97
    li2[si] += 1
    li1[si] -= 1

    t = 0
    for i in range(26):
        if li1[i] > 0 and li2[i] > 0:
            t += 1

    ans = max(ans, t)

print(ans)

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

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

ans = 0
for i in range(N - 1):
    a = S[:i + 1]
    b = S[i + 1:]
    count = 0
    for j in range(97, 123):
        if chr(j) in a and chr(j) in b:
            count += 1
    if count > ans:
        ans = count
print(ans)

Solution (Python):
import collections

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

ans=0
X=collections.Counter()
Y=collections.Counter(S)
for c in S:
    X[c]+=1
    Y[c]-=1
    ans=max(ans,len(X&Y))
       
print(ans)

Solution (Python):
from collections import Counter

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

ans=0
X=Counter()
Y=Counter(S)
for c in S:
    X[c]+=1
    Y[c]-=1
    ans=max(ans,len(X&Y))
       
print(ans)

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

ans=0
for i in range(1,N-1):
    a=[0]*26
    for j in range(i):
        a[ord(S[j])-97]|=1
    for j in range(i,N):
        a[ord(S[j])-97]|=2
    ans=max(ans,a.count(3))

print(ans)

Solution (Python):
from collections import Counter

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

ans=0
X=Counter()
Y=Counter(S)
for c in S:
    Y[c]-=1
    if Y[c]==0:
        del X[c]
    else:
        X[c]+=1
    ans=max(ans,len(X))
       

print(ans)

Solution (Python):
from collections import Counter
N=int(input())
S=input()

ans=0
l=Counter()
r=Counter(S)
for c in S:
    l[c]+=1
    r[c]-=1
    ans=max(ans,len(l&r))

print(ans)

Solution (Python):









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

ans = 0
for i in range(n-1):
    cnt = 0
    f = set(s[:i+1])
    b = set(s[i+1:])
    tmp = []
    if (len(f) >= len(b)):
        tmp = list(set(s[:i+1]))
        tmp2 = list(s[i+1:])
    else:
        tmp = list(set(s[i+1:]))
        tmp2 = list(s[:i+1])
    for i in range(len(tmp)):
        if tmp[i] in tmp2:
            cnt += 1
    ans = max(ans, cnt)
print(ans)

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

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

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

for i in range(N):
  ans = 0
  for j in range(N):
    f = {}
    b = {}
    for k in range(j):
      if S[k] in f.keys():
        f[S[k]] += 1
      else:
        f[S[k]] = 1
        
    for k in range(N-j):
      if S[N-k-1] in b.keys():
        b[S[N-k-1]] += 1
      else:
        b[S[N-k-1]] = 1

    for k in range(N):
      common = 0
      for l in f.keys():
        if l in b.keys():
          common += 1
     
      if common > ans:
        ans = common
        
print(ans)

Solution (Python):
N = int(input())
S = input()
answer = 0
for i in range(1,N-1):
  X = S[:i]
  Y = S[i:]
  Z = 0
  for c in 'abcdefghijklmnopqrstuvwxyz':
    if c in X and c in Y:
      Z += 1
  answer = max(answer,Z)
print(answer)

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())
    S = readline().strip()

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

    print(ans)
    return


if __name__ == '__main__':
    main()

Solution (Python):
from collections import Counter
n = int(input())
s = list(input())
print(max([len(Counter(s[:i]).keys() & Counter(s[i:]).keys()) for i in range(1,n+1)]))

Solution (Python):
from collections import Counter
n = int(input())
s = list(input())
print(max([len(Counter(s[:i]).keys() & Counter(s[i:]).keys()) for i in range(1,n+1)]))

Solution (Python):
from collections import Counter

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

ans = 0

for i in range(1, n - 1):
    ans = max(ans, len(Counter(s[:i]).keys() & Counter(s[i:]).keys()))

print(ans)

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

ans = 0

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

print(ans)

Solution (Python):
def main():
    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)
main()

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

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

Solution (Python):
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

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

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

ans = 0

for i in range(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())
m=0
for i in range(N):
    s1=S[i:]
    s2=S[:i]
    m = max(m,len(list(set(s1)&set(s2))))
print(m)

Solution (Python):
n = int(input())
s = list(input())
ans = 0
for i in range(1,n-1):
  a = set(s[:i])
  b = s[i:]
  t = 0
  for j in a:
    if j in b:
      t += 1
  ans = max(ans, t)
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 = list(input())
a = []
for i in range(1, N):
  a.append(len(list(set(s[0:i]) & set(s[i:]))))
print(max(a))

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

ans = 0
for i in range(n):
    d1, d2 = {}, {}
    for j in range(i):
        d1[s[j]] = 0
    for j in range(i, n):
        if s[j] in d1 and s[j] not in d2:
            d2[s[j]] = 0
    ans = max(ans, len(d2))

print(ans)

Solution (Python):
n = int(input())
s = list(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-1):
    ls=set(s[0:i+1])
    rs=set(s[i+1:n])
    cnt=0
    for l in ls:
        if l in rs:
            cnt+=1
    ans=max(cnt,ans)
print(ans)

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

ans = 0

for i in range(n):
    one = s[0:i]
    other = s[i:]
    now = 0
    one = set(one)

    for j in one:
        for k in other:
            if j == k:
                now += 1
                break

    ans = max(now, ans)

print(ans)

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

Solution (Python):
def resolve():
    N = int(input())
    S = input()
    ans = []
    abc = "abcdefghijklmnopqrstuvwxyz"
    for i in range(N-1):
        X = S[:i+1]
        Y = S[i+1:]
        count = 0
        for j in abc:
            if j in X and j in Y:
                count += 1
        ans.append(count)
    print(max(ans))
resolve()

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

a = [0]*N

for i in range(1, N):
    b = []
    for s in S[:i]:
        if s in S[i:] and s not in b:
            a[i] += 1
            b.append(s)

print(max(a))

Solution (Python):
import string

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

result = 0
for i in range(1, N+1):
    S_forward = S[:i]
    S_backward = S[i:]
    is_same = 0
    for j in string.ascii_lowercase:
        if j in S_forward and j in S_backward:
            is_same += 1
    result = max(result, is_same)

print(result)

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

result = 0
for i in range(1, N+1):
    S_forward = S[:i]
    S_backward = S[i:]
    is_same = []
    for j in S_forward:
        if j in S_backward:
            if j not in is_same:
                is_same.append(j)
    result = max(result, len(is_same))

print(result)

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()
max = 0

for i in range(1, len(s)):
    u = len(set(s[:i]).intersection(set(s[i:])))
    if u > max:
        max = u

print(max)

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

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

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

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

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

print(MAX)

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

ans = 0

for l in range(n):
    ans = max(len(set(s[:l]).intersection(set(s[l:]))), ans)

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()
res=0
for i in range(1,n):
    a=s[:i]
    b=s[i:]
    sum=0
    for j in range(97,123):
        x=chr(j)
        if x in a and x in b:
            sum+=1
    res=max(sum,res)
print(res)

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

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

for i in range(N):
  L = S[:i]
  R = S[i:]
  ans = max(ans, len(set(L)&set(R)))

print(ans)

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

def solve(x,y):

    sx = set(x)
    sy = set(y)
    s_com = sx & sy
    return len(s_com)

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

print(ans)

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

Solution (Python):


import math

import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd


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

Solution (Python):

n = int(input())
s = input()
x,y = "",""
Max = 0

for i in range(1,n):
    x = list(set(list(s[:i])))
    y = list(set(list(s[i:])))
    cnt = 0
    for m in x:
        for n in y:
            if m == n:
                cnt +=1
                break
        if Max < cnt:
            Max = cnt
            
print(Max)

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

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

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

res = 0

for i in range(1,n):
    temp =""
    x = s[:i]
    y = s[i:]
    for j in range(i):
        if s[j] in y:
            temp +=s[j]
    res = max(res,len(set(temp)))

print(res)

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

print(ans)

Solution (Python):
n=int(input())
s=input()
count=0
for i in range(n):
  str_1=s[0:i-1]
  str_2=s[i-1:n]
  if count<len(set(str_1)&set(str_2)):
    count=len(set(str_1)&set(str_2))
print(count)

Solution (Python):




import numpy as np

def int_mtx(N):
    x = []
    for _ in range(N):
        x.append(input())
    return x

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

ans = 0

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

print(ans)

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

answer = 0
for index in range(1,len(s)-1):
  x = list(set(s[:index]))
  y = list(set(s[index:]))
  count = 0
  if len(x) > len(y):
    for check in x:
      if check in y:
        count += 1
  else:
    for check in y:
      if check in x:
        count += 1
  if count > answer:
    answer = count
  
print(answer)

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

al = [chr(ord('a') + i) for i in range(26)]
left =[]
right = []
for i in S:
    right.append(i)

ans = 0

for i in range(len(S)):
    left.append(right[0])
    right.pop(0)
    aaa = 0
    for i in al:
        if i in left and i in right:
            aaa += 1
    ans = max(ans,aaa)

print(ans)

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


max_count = 0
for i in range(len(s)):
    ss = "abcdefghijklmnopqrstuvwxyz"
    x_dict = {}
    y_dict = {}
    for c in ss:
        x_dict[c] = 0
        y_dict[c] = 0
        
    
    
    x = s[:i]
    y = s[i:]
    
    
    for xx in x:
        x_dict[xx] += 1
        
    for yy in y:
        y_dict[yy] += 1
    
    
    
    
    count = 0
    for c in ss:
        
        if x_dict[c] > 0 and y_dict[c] > 0:
            
            count += 1
    
    max_count = max(max_count, count)
        
print(max_count)

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

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

Solution (Python):


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


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

print(ans)

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

ans = 0
for i in range(1, n-1):
    X = S[:i]
    Y = S[i:]
    tmp = len(set(X) & set(Y))
    ans = max(ans, tmp)
print(ans)

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

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

Solution (Python):
import collections
a=int(input())
b=input()
result=[]
for i in range(1,a):
    n=b[:i]
    m=b[i:]
    n=collections.Counter(n)
    m=collections.Counter(m)
    n,o1=zip(*n.most_common())
    m,o2=zip(*m.most_common())
    n=set(n)
    m=set(m)
    s_i=n&m
    s_i=len(s_i)
    result.append(s_i)
print(max(result))

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

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

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

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

print(ans)

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

Solution (Python):
N=int(input())
S=input()
s=""
m=""
ss=[]
mm=[]
s1=set()
m1=set()
res = 0
for i in range(N):
  s=S[0:i+1]
  m=S[i+1:N]
  ss=list(s)
  mm=list(m)
  s1=set(ss)
  m1=set(mm)
  s_intersection = s1 & m1
  res= max(res,len(s_intersection))
print(res)

Solution (Python):
N = int(input())
S = input()
maxi = 0
for i in range(1,N):
  a = S[0:i]
  b = S[i:]
  aa = set(a)
  bb = set(b)
  ans = bb&aa
  if len(ans) > maxi:
    maxi = len(ans)
print(maxi)

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

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

    for j in S:
        if j in s2:
            c += 1
    cnt = max(cnt, c)

print(cnt)

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

for i in range(1,len(s)):
    f = s[:i]
    g = s[i:]
    
    x = set(f)
    count = 0
    
    for j in x:
        if j in g:
            count = count+1
    m = max(count,m)

print(m)

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

s = list(input())

ans = 0

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

print(ans)

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

lst = []
for i in range(1,n-1):
    left = s[:i]
    right = s[i:]

    cnt = 0
    for j in set(left):
        if j in set(right):
            cnt += 1
    lst.append(cnt)

if not lst:
    print(0)
else:
    print(max(lst))

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

for i in range(1, n):
    a = s[:i]
    b = s[i:]
    a_al = []
    ans_t = 0

    for k in range(len(a)):
        for l in range(len(b)):
            if a[k] in a_al:
                continue
            if a[k] == b[l]:
                ans_t += 1
                a_al.append(a[k])
    if ans_t > ans:
        ans = ans_t

print(ans)

Solution (Python):

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

ans=0
for i in range(1,N):
    X = S[0:i]
    Y = S[i:N]
    cnt=0
    

    als=[chr(ord('a') + i) for i in range(26)]
    for al in als:
        if (al in X) and (al in Y):
            cnt+=1
    ans=max(ans,cnt)
print(ans)

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

ans = 0

for k in range(1, N):
    ans = max(ans, len(set(S[:k])&set(S[k:])))
    
print(ans)

Solution (Python):
def main():
    import sys

    def input(): return sys.stdin.readline().rstrip()
    
    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)

            



if __name__ == '__main__':
    main()

Solution (Python):

n=int(input())
s=input()
ans = 0
for i in range(1,n):
    a = {j for j in s[:i]}
    b = {j for j in s[i:]}
    ans = max(ans, len(a & b))
print(ans)

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