Problem:
 Score : 200 points    Problem Statement You are given a string S of length N consisting of lowercase English letters.
We will cut this string at one position into two strings X and Y .
Here, we would like to maximize the number of different letters contained in both X and Y .
Find the largest possible number of different letters contained in both X and Y when we cut the string at the optimal position.      Constraints  2 \leq N \leq 100  |S| = N  S consists of lowercase English letters.         Input Input is given from Standard Input in the following format:  N  S       Output Print the largest possible number of different letters contained in both X and Y .        Sample Input 1 6
aabbca      Sample Output 1 2  If we cut the string between the third and fourth letters into X =  aab and Y =  bca , the letters contained in both X and Y are a and b .
There will never be three or more different letters contained in both X and Y , so the answer is 2 .       Sample Input 2 10
aaaaaaaaaa      Sample Output 2 1  However we divide S , only a will be contained in both X and Y .       Sample Input 3 45
tgxgdqkyjzhyputjjtllptdfxocrylqfqjynmfbfucbir      Sample Output 3 9

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

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

Solution (Python):
n = int(input())
s= input()
ans  = 0
for i in range(n):
    x = list(set(s[:i]))
    y = list(set(s[i::]))
    k = x+y
    m = len(x)+len(y)
    ans = max(ans , m - len(set(k)))

    
print(ans)

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

for i in range(1, n):
    a=s[:i]
    b=s[i:]
    dic=[]
    dic2=[]
    for j in range(len(a)):
        if a[j] not in dic:
            dic.append(a[j])
    for k in range(len(b)):
        if b[k] not in dic2:
            dic2.append(b[k])

    l=min(len(dic), len(dic2))
    cnt=0
    if l==len(dic):
        for j in range(len(dic)):
            if dic[j] in dic2:
                cnt+=1
    else:
        for k in range(len(dic2)):
            if dic2[k] in dic:
                cnt+=1
    
    ans=max(ans, cnt)
    
print(ans)

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

c = 0
for i in range(N):
    l = set(S[:i])
    r = set(S[i:])
    dp = len(l&r)
    if c < dp:
        c = dp

print(c)

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

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

Solution (Python):
n = int(input())
s = input()
v = [0] * n
for c in range(ord('a'), ord('z') + 1):
  p = -1
  for i in range(n):
    if ord(s[i]) == c:
      if p >= 0:
        v[i] -= 1
        v[p] += 1
      p = i
ans = 0
vsum = 0
for i in v:
  vsum += i
  ans = max(ans, vsum)
print(ans)

Solution (Python):
import sys
from io import StringIO
import unittest

def resolve():
    n = int(input())
    s = list(input())

    ans = 0
    for i in range(len(s) - 1):
        left = s[0:i + 1]
        right = s[i + 1:]

        tmp_ans = len(set(left) & set(right))

        
        
        ans = max(ans, tmp_ans)

    print(ans)


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """6
aabbca"""
        output = """2"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """10
aaaaaaaaaa"""
        output = """1"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """45
tgxgdqkyjzhyputjjtllptdfxocrylqfqjynmfbfucbir"""
        output = """9"""
        self.assertIO(input, output)

if __name__ == "__main__":
    
    resolve()

Solution (Python):
import sys
from io import StringIO
import unittest

def resolve():
    n = int(input())
    s = list(input())

    ans = 0
    for i in range(len(s) - 1):
        left = s[0:i + 1]
        right = s[i + 1:]

        tmp_ans = len(set(left) & set(right))

        if ans < tmp_ans:
            ans = tmp_ans

    print(ans)


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """6
aabbca"""
        output = """2"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """10
aaaaaaaaaa"""
        output = """1"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """45
tgxgdqkyjzhyputjjtllptdfxocrylqfqjynmfbfucbir"""
        output = """9"""
        self.assertIO(input, output)

if __name__ == "__main__":
    
    resolve()

Solution (Python):
n = int(input())
s = list(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()
ans=0
for i in range(1,n):
  s1=set(s[:i])
  s2=set(s[i:])
  com = s1 & s2
  ans = max(ans,len(com))
print(ans)

Solution (Python):
n = int(input())
s = list(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):

import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial
from bisect import bisect_left 
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri(x): print('\n'.join(map(str, x)))

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

res = 0
for i in range(N):
    s1 = S[:i]
    s2 = S[i:]
    ss1, ss2 = set(s1), set(s2)
    s = ss1&ss2
    val = len(s)
    if res < val:
        res = val

print(res)

Solution (Python):

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

print(ans)

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
inf = 10**17
mod = 10**9 + 7

n=I()
s=input().rstrip()
alphasm=[chr(i) for i in range(97, 97+26)]
num=[]
for i in range(n):
    count=0
    k=list(s[0:i])
    l=list(s[i:n])
    for char in alphasm:
        if (char in k) and (char in l):
            count+=1
    num.append(count)
print(max(num))

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()
print(max([len(set(s[:i + 1]) & set(s[i + 1:])) for i in range(n - 1)]))

Solution (Python):
n = int(input())
s = input()
tmp = []
for i in range(1, n):
    tmp.append([s[0:i], s[i:n]])

m = 0
for i in range(len(tmp)):
    cnt = 0
    tmp2 = []
    for j in range(len(tmp[i][0])):
        if tmp[i][0][j] in tmp[i][1] and tmp[i][0][j] not in tmp2:
            cnt += 1
            tmp2.append(tmp[i][0][j])
    if cnt > m:
        m = cnt
print(m)

Solution (Python):
n=int(input())
s=input()
al=list("abcdefghijklmnopqrstuvwxyz")
count=0
ans=0
for i in range(1,n):
  left=set(s[:i])
  right=set(s[i:])
  for j in al:
    if j in left and j in right:
      count+=1
  if ans<=count:
    ans=count
  count=0
print(ans)

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

Solution (Python):
n = int(input())
s = input()
ans = 0
for i in range(n-1):
    s1 = s[:i+1]
    s2 = s[i+1:]
    S1 = set(s1)
    S2 = set(s2)
    num = S1 & S2
    ans = max(ans,len(num))
print(ans)

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

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

Solution (Python):
n=int(input())
s=input()
keep=-1
for i in range(0,n-1):
  left=s[:i+1]
  migi=s[i+1:]
  lis=[]
  count=0
  for j in range(0,len(left)):
    t=left[j]
    if not t in lis:
      if t in migi:
        count+=1
    lis.append(t)
  if count>keep:
    keep=count
print(keep)

Solution (Python):
from collections import OrderedDict

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

ans = 0
for i in range(N):
    if (i == N - 1):
        break
    L = ''.join(OrderedDict.fromkeys(S[0:i + 1]))
    R = ''.join(OrderedDict.fromkeys(S[i + 1:]))
    count = 0
    for j in range(len(L)):
        if (L[j] in R):
            count += 1
        else:
            continue
    ans = max(ans, count)

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=[]
    for l in L:
        if not l in C:
            if l in R:
                C.append(l)
    ans=max(len(C),ans)
print(ans)

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

Solution (Python):
n = int(input())
s = input()
Max = 0
for i in range(1, len(s)): 
    length = len(set(s[:i]) & set(s[i:]))
    if length > Max:
        Max = length
print(Max)

Solution (Python):
import sys
input = sys.stdin.readline


def read():
    N = int(input().strip())
    S = input().strip()
    return N, S


def solve(N, S):
    Z = 26
    cl = [[0 for j in range(Z)] for i in range(N)]  
    cr = [[0 for j in range(Z)] for i in range(N)]  
    for i in range(N):
        if i > 0:
            for j in range(Z):
                cl[i][j] = cl[i-1][j]
        s = ord(S[i]) - ord('a')
        cl[i][s] += 1
    for i in range(N-1, -1, -1):
        if i < N-1:
            for j in range(Z):
                cr[i][j] = cr[i+1][j]
        s = ord(S[i]) - ord('a')
        cr[i][s] += 1

    max_chars = 0
    for i in range(1, N):
        chars = 0
        for j in range(Z):
            if cl[i-1][j] > 0 and cr[i][j] > 0:
                chars += 1
        max_chars = max(max_chars, chars)
    return max_chars


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))

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

type_num = 0
for i in range(1,n):
    left_s = list(set(s[0:i]))
    right_s = list(set(s[i:n]))
    
    tmp = 0
    for j in left_s:
        if j in right_s:
            tmp += right_s.count(j)
            type_num = max(type_num, tmp)
print(type_num)

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

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

print(ans)

Solution (Python):





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

    ans = 0
    for i in range(1, N):
        X = S[:i]
        Y = S[i:]
        tmp = 0
        for code in range(97, 97+26):
            c = chr(code)
            if c in X and c in Y:
                tmp += 1
        
        if tmp > ans:
            ans = tmp
        
    return ans


print(main())

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

Solution (Python):
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop

import collections

n = int(input())
s = input()
u = ""
v = ""
ans = 0
for i in range(n):
    u += s[i]
    v = ""
    for j in range(i+1,n):
        v += s[j]
    u2 = collections.Counter(u)
    v2 = collections.Counter(v)
    ukey = []
    vkey = []
    for key in u2.keys():
        ukey.append(key)
    for key in v2.keys():
        vkey.append(key)
    same = 0
    for i in ukey:
        for j in vkey:
            if i == j:
                same += 1
    ans = max(ans,same)
print(ans)

Solution (Python):
from collections import Counter
n = int(input())
s = str(input())

ans = 0
for i in range(1,n):
    tmp1 = Counter(s[:i]).keys()
    tmp2 = Counter(s[i:]).keys()

    same = set(tmp1) & set(tmp2)

    if len(same) > ans:
        ans = len(same)

print(ans)

Solution (Python):
import sys
import time
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

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

if __name__ == '__main__':
    main()

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

Solution (Python):
N = int(input())
S = input()
cnts = []
for i in range(N-1):
    A = set(S[0:i+1])
    B = set(S[i+1:N])
    cnt = 0
    for a in A:
        if a in B:
            cnt += 1
    cnts.append(cnt)
print(max(cnts))

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

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

Solution (Python):
n=int(input())
s=input()
m=0
for i in range(n):
  s1=s[:i]
  a1=set()
  for j in s1:
    a1.add(j)
  s2=s[i:]
  a2=set()
  for j in s2:
    a2.add(j)
  uni=a1 & a2
  if m<len(uni):
    m=len(uni)
print(m)

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

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

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

Solution (Python):
import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from fractions import gcd
from math import factorial, sqrt, ceil
from functools import lru_cache, reduce
INF = 1 << 60
MOD = 1000000007
sys.setrecursionlimit(10 ** 7)


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def dijkstra_heap(s, edge, n):
    
    d = [10**20] * n
    used = [True] * n 
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


def lcm(x, y):
    return (x * y) // gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm, numbers, 1)


def gcd_list(numbers):
    return reduce(gcd, numbers)


def is_prime(n):
    if n <= 1:
        return False
    p = 2
    while True:
        if p ** 2 > n:
            break
        if n % p == 0:
            return False
        p += 1
    return True



def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []

    while True:
        prime = min(A)
        
        if prime > sqrt(limit):
            break
            
        P.append(prime)
            
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
            
    for a in A:
        P.append(a)
            
    return P


def permutation_with_duplicates(L):

    if L == []:
        return [[]]

    else:
        ret = []

        
        S = sorted(set(L))

        for i in S:

            data = L[:]
            data.remove(i)

            for j in permutation_with_duplicates(data):
                ret.append([i] + j)

        return ret



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

Solution (Python):
n = int(input())
s = [i for i in input()]

import collections
ans = 0
for i in range(1, n):
    
    c1 = collections.Counter(s[:i])
    c2 = collections.Counter(s[i:])
    p = c1.keys() & c2.keys()
    
    if len(p) > ans:
        ans = len(p)
print(ans)

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

    count = 0
    max_count = 0
    for i in range(N - 1):
        if S[i] not in S[:i]:
            if S[i] in S[i + 1:]:
                count += 1
        elif S[i] not in S[i + 1:]:
            count -= 1
        max_count = max(count, max_count)

    print(max_count)

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

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

ans = 0
for i in range(1, n):
    x = s[0:i] 
    y = s[i:n]
    xl = list(x)
    yl = list(y)
    cnt = 0
    pre = []
    for j in range(len(xl)):
        if xl[j] in yl and xl[j] not in pre:
            cnt += 1
            pre.append(xl[j])
    if ans < cnt:
        ans = cnt
print(ans)

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

max_chars = 0
for i in range(1, len(s)):
    s1, s2 = s[:i], s[i:]
    s1_chars = set(s1)
    s2_chars = set(s2)

    same_chars = s1_chars & s2_chars
    max_chars = max(max_chars, len(same_chars))

print(max_chars)

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

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

print(ans)

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

for i in s:
    a.append(i)

for i in range(n - 1):
    b = set(a[:i + 1]) & set(a[i + 1:])
    ans = max(ans, len(b))

print(ans)

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

Solution (Python):
N = int(input())
S = list(input())
count = 0
for a in range(1,N-2):
    b = set(S[0:a])
    c = set(S[a:])
    d = len(b&c)
    if d > count:
        count = d

print(count)

Solution (Python):

import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

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

if __name__ == '__main__':
    main()

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

Solution (Python):
import numpy as np
N=int(input())
S=str(input())
s_list = "abcdefghijklmnopqrstuvwxyz"
max_count = 0
for i in range(1,N-1): 
  count_list = np.zeros(26)
  for k in range(i):

    if S[k] in S[i:len(S)]:
      count_list[s_list.index(S[k])] = count_list[s_list.index(S[k])] + 1
  if max_count < len([1 for x in count_list if x>0]):
    max_count = len([1 for x in count_list if x>0])

print(max_count)

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

res = 0
for i in range(n):
    s1 = set(s[:i])
    s2 = set(s[i:])

    res = max(res,len(s1&s2))
print(res)

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

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

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

for i in range(1, n):
    a,b = set(s[:i]), set(s[i:])
    if max(len(a),len(b))-max(len(a-b),len(b-a))>x:
        x = max(len(a),len(b))-max(len(a-b),len(b-a))

print(x)

Solution (Python):
import sys


def main():
    N = int(input())
    S = input()
    
    for i in range(N):
        left = set(S[:i])
        right = set(S[i:])

        yield len(left & right)


print(max(main()))

Solution (Python):

n = int(input())
s = input()
cnt = 0
for i in range(n):
    s1 = s[:i]
    s2 = s[i:]
    tmp = len(set(s1)&set(s2))
    if cnt < tmp:
        cnt = tmp
print(cnt)

Solution (Python):
N = int(input())
S = input()
s = set(S)
count = 0
maxx = 0
for i in range(N): 
    for k in range(i):
        if S[k] in S[:i] and S[k] in S[i:] and S[k] not in S[:k]:
            count += 1
    maxx = max(maxx, count)
    count = 0
print(maxx)

Solution (Python):
N = int(input())
S = list(input())
s = set(S)
count = 0
maxx = 0
for i in range(N): 
    for k in range(i):
        if S[k] in S[:i] and S[k] in S[i:] and S[k] not in S[:k]:
            count += 1
    maxx = max(maxx, count)
    count = 0
print(maxx)

Solution (Python):
from collections import Counter

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

counter = Counter(S)
ans = 0
for i in range(1, N):
    left_counter = Counter(S[:i])
    right_counter = Counter(S[i:])
    left_set = set(left_counter.keys())
    right_set = set(right_counter.keys())
    common_set = left_set & right_set
    ans = max(ans, len(common_set))

print(ans)

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

for i in range(N):
  x = set(list(S[0:i]))
  y = set(list(S[i:len(S)]))
  if len(x & y) > max:
    max = len(x & y)

print(max)

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

ans = 0
for i in range(1,N):
    cnt = 0
    zenhan = list(set(S[:i]))
    kouhan = list(set(S[i:]))
    for j in zenhan:
        if kouhan.count(j) == 1:
            cnt += 1
    else:
        ans = max(ans,cnt)
print(ans)

Solution (Python):
N=int(input())
S=input()
counter=0
alpha=list(set(list(S)))
for i in range(1,N):
    st=S[:i]
    gr=S[i:]
    count=0
    for j in range(0,len(alpha)):
        if st.count(alpha[j])!=0 and gr.count(alpha[j])!=0:
            count+=1
    if counter<count:
        counter=count
print(counter)

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 = int(input())
s = input()
ans = 0
for i in range(n - 1):
    cnt = 0
    x = set(s[:i + 1])
    y = set(s[i + 1:n])
    cnt = len(x & y)
    if cnt > ans:
        ans = cnt
print(ans)

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

Solution (Python):
import collections
n=int(input())
s=input()
ans=0
for i in range(1,n-1):
    l=list(set(s[:i]) & set(s[i:]))
    c = collections.Counter(l)
    ans=max(ans,len(c.keys()))
print(ans)

Solution (Python):
def myAnswer(N:int,S:list) -> int:
   ans = 0
   for i in range(1,N):
      left = set(S[:i])
      right = set(S[i:])
      counter = 0
      for l in left:
         if(l in right):
            counter += 1
      ans = max(ans,counter)

   return ans

def modelAnswer():
   return
def main():
   N = int(input())
   S = list(input())
   print(myAnswer(N,S[:]))

if __name__ == '__main__':
   main()

Solution (Python):
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
s = list(input())
ans = 0
for i in range(1,n):
    be = set(s[:i])
    en = set(s[i:])
    ans = max(ans,len(be&en))

print(ans)

Solution (Python):

import sys


def solve(N: int, S: str):
    print(max(len(set(S[:i]) & set(S[i:])) for i in range(1, N)))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    S = next(tokens)  
    solve(N, S)


if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
S = input()
ans = []
tmp = 0
for i in range(N):
    for j in range(97,123):
        A = S[:i]
        B = S[i:]
        if A.count(chr(j)) > 0 and B.count(chr(j)) > 0:
            tmp += 1
    ans.append(tmp)
    tmp = 0
print(max(ans))

Solution (Python):
n=int(input())
s1=list(input())
s2=set()
s3=set()
tmp_s2=[]
tmp_s3=[]
max=0
for i in range(n-1):
    for j in range(i+1):
        tmp_s2.append(s1[j])
    s2=set(tmp_s2)
    tmp_s2.clear()
    for j in range(i+1,n):
        tmp_s3.append(s1[j])
    s3=set(tmp_s3)
    tmp_s3.clear()
    if max<len(s2&s3):
        max=len(s2&s3)
    s2.clear()
    s3.clear()
print(max)

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

max=0

for i in range(1,(N)):
  a=S[:i]
  b=S[i:]
  L= len(set(a)&set(b))
  if L>max:
    max=L
print(max)

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

a=[]
b=[]
max=0

for i in range(1,(N)):
  a=[]
  b=[]
  for j in range(i):
    
    a.append(S[j])
  
  for j in range(i,N):
    
    b.append(S[j])
  
  if len(set(a)&set(b))>max:
    max=len(set(a)&set(b))
print(max)

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

Solution (Python):
def resolve():
    '''
    code here
    '''
    N = int(input())
    S = input()

    res = 0
    for i in range(1, N):
        A = set(S[:i])
        B = set(S[i:])

        res = max(res, len(A & B))

    print(res)

if __name__ == "__main__":
    resolve()

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

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

Solution (Python):
N=int(input())
S=input()
max_1=0
for i in range(1,N):
  count=0
  counted=[]
  A=S[:i]
  B=S[i:]
  for j in A:
    if j not in counted and j in B:
      count+=1
      counted.append(j)
  max_1=max(max_1,count)

print(max_1)

Solution (Python):
from collections import Counter

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

ans = 0
for i in range(1,N):
    temp = 0
    left = S[:i]
    right = S[i:]
    left_words = Counter(left)
    right_words = Counter(right)
    for key1 in left_words.keys():
        for key2 in right_words.keys():
            if key1 == key2:
                temp += 1
    if temp > ans:
        ans = temp
print(ans)

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

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

print(ans)

Solution (Python):

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

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

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

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

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:])
    c=a&b
    if len(c)>ans:
        ans=len(c)

print(ans)

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

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

Solution (Python):
N = int(input())
S = str(input())
cl = [0]*N
for i in range(1,N):
  Y = S[i:]
  X = S[:i]
  X = list(set(X))
  Y = list(set(Y))
  count = 0
  for j in range(len(X)):
    for k in range(len(Y)):
      if X[j] == Y[k]:
        count += 1
  cl[i] = count

print(max(cl))

Solution (Python):
import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    S = iss()
    print(max(len(set(S[:n]) & set(S[n:])) for n in range(N)))


if __name__ == '__main__':
    main()

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

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

i=0
ans=[]
while i<N:
    A=set(S[:i])
    B=set(S[i:])
    j=0
    count=0
    while j<len(A):
        count+=1*(list(A)[j]in B)
        j+=1
    ans.append(count)
    i+=1

print(max(ans))

Solution (Python):
icase=0
if icase==0:
    n=int(input())
    s=list(input())
    icmax=0
    for i in range(n):
        si=set(s[0:i])
        ti=set(s[i:n])
        icnt=len(si&ti) 
        icmax=max(icmax,icnt)
    print(icmax)

Solution (Python):
def countboth(s1,s2): 
    count = 0
    alph = 'abcdefghijklmnopqrstuvwxyz'
    if len(s1)*len(s2) == 0:
        return 0
    
    for a in alph:
        if a in s1 and a in s2:
            count += 1
    return count

n = int(input())
s = input()
cmax = 0
i = 1
while i < n-1:
    if i < (n/2):
        s1, s2 = s[:i],s[i:]
    else:
        s2, s1 = s[:i],s[i:]
    cmax = max(countboth(s1,s2), cmax)
    i += 1
print(cmax)