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

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

Solution (Python):
N = int(input())
S = input()
ans = 0
for i in range(N):
    x = S[:i]
    y = S[i:]
    x_y = set(x) & set(y)
    ans = len(x_y) if len(x_y) > ans else ans
print(ans)

Solution (Python):
def cut_and_count(N: int, S: str) -> int:
    l, r = {}, {}
    for c in S:
        if c not in r:
            r[c] = 1
        else:
            r[c] += 1

    max_len = 0
    for c in S:
        if c not in l:
            l[c] = 1
        else:
            l[c] += 1
        r[c] -= 1

        ls = set(k for k, v in l.items() if v > 0)
        rs = set(k for k, v in r.items() if v > 0)

        temp = len(ls & rs)
        max_len = max(max_len, temp)

    return max_len


if __name__ == "__main__":
    N = int(input())
    S = input()
    ans = cut_and_count(N, S)
    print(ans)

Solution (Python):
N = int(input())
S = input()
S0 = list(S)
max_S3 = 0

for i in range(N):
  dic1 = {}
  dic2 = {}
  S1 = S0[:i+1]
  S1 = set(S1)
  S2 = S0[i+1:]
  S2 = set(S2)
  S3 = list(S1 & S2)
  if(max_S3 < len(S3)):
   max_S3 = len(S3)
  
print(max_S3)

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

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

def f(l,r):
    li=[]
    re=0
    for i in range(len(l)):
        if l[i] in r and l[i] not in li:
            re+=1
            li.append(l[i])
    return re
            
ans=0

for i in range(1,n):
    sl=s[:i]
    sr=s[i:]
    ans=max(ans,f(sl,sr))

print(ans)

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

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

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

Solution (Python):
N = int(input())
S = [i for i in input()]
anslist = []
for i in range(N):
    ans = 0
    left =set(S[:i])
    rigth=set(S[i:])
    for j in left:
        for r in rigth:
            if j==r:
                ans+=1
    anslist.append(ans)
print(max(anslist))

Solution (Python):
n = int(input())
s = list(input())
count_L = [0] * 26
count_R = [0] * 26
ans = []
for i in range(n-1):
    count_L = [0] * 26
    count_R = [0] * 26
    c = 0
    for j in range(0,i+1):
        count_L[ord(s[j])-97] += 1
    for j in range(i+1,n):
        count_R[ord(s[j])-97] += 1
    

    for j in range(26):
        if count_L[j] > 0 and count_R[j] > 0:
            c += 1
    ans.append(c)
print(max(ans))

Solution (Python):

N = int(input())
S = input()
ans = 0
for i in range(N):
    n = 0
    X, Y = set(S[:i + 1]), set(S[i + 1:])
    for x in X:
        if x in Y:
            n += 1
    if ans < n:
        ans = n
print(ans)

Solution (Python):
N = int(input())
S = input()
ans = 0
for i in range(N):
    d1 = {}
    d2 = {}
    S1 = S[:i]
    S2 = S[i:]
    subans = 0
    for s in S1:
        d1[s] = True
    for s in S2:
        d2[s] = True
    for key in d1:
        if key in d2:
            subans += 1
    ans = max(ans, subans)
print(ans)

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

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

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

ans = 0
for i in range(N):
  cnt = 0
  l = list(set(S[:i]))
  r = list(set(S[i:]))
  for ls in l:
    if(ls in r):
      cnt += 1
  ans = max(ans, cnt)
print(ans)

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

result = 0
for i in range(N-1):
    X = S[:i+1]
    Y = S[i+1:]
    setX = set(X)
    setY = set(Y)
    if setX & setY:
        result = max(len(list(setX & setY)), result)
print(result)

Solution (Python):
N = int(input())
s = input()
ans = 0
for i in range(N):
    l = set()
    r = set()
    tmp = 0
    x = s[0:i]
    y = s[i:]
    for j in x:
        l.add(j)
    for j in y:
        r.add(j)
    for j in l:
        if j in r:
            tmp += 1
    ans = max(ans,tmp)
print(ans)

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

Solution (Python):
n = int(input())
s = input()
maxcount = 0
for i in range(1, n):
	count = 0
	marked = []
	for j in range(i):
		if s[j] in marked:
			continue
		if s[i:].count(s[j]) > 0:
			count += 1
			marked.append(s[j])
	maxcount = max(count, maxcount)
print(maxcount)

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

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

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

count = 0
for i in range(N):
    a = S[0:i]
    b = S[i:]
    cache = 0
    obj = []
    for j in range(len(a)):
        if a[j] not in obj:
            if a[j] in b:
                obj.append(a[j])
                cache += 1

    if cache > count:
        count = cache

print(count)

Solution (Python):
n=int(input())
s=input()
al="abcdefghijklmnopqrstuvwxyz"
candidate=[]
count=0
for i in range(n-1):
    for j in al:
        if j in s[:i+1] and j in s[i+1:]:
            count+=1
    candidate.append(count)
    count=0
candidate.sort()
print(candidate[-1])

Solution (Python):

n = int(input())
s = input()
r = []
for i in range(len(s) - 1):
    x = s[:i+1]
    y = s[-len(s) + 1 + i:]
    r.append(len(set(x) & set(y)))
print(max(r))

Solution (Python):
def main():
    N = int(input())
    S = input()
    ans = 0
    for i in range(1, N):
        s1 = set(S[:i])
        s2 = set(S[i:])
        tmp = 0
        for c in s1:
            if c in s2:
                tmp += 1
        ans = max(ans, tmp)
    print(ans)


if __name__ == "__main__":
    main()

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

alphabets = 'abcdefghijklmnopqrstuvwxyz'

ans = 0

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

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

Solution (Python):
N=int(input())
S=input()
L=[]
for i in range(0,N):
  L1=list(S[0:i]);L2=list(S[i:N])
  L.append(len(list(set(L1)&set(L2))))
print(max(L))

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

if n == 2:
    if s[0] == s[1]:
        print(1)
        exit()
    else:
        print(0)
        exit()

for i in s:
    S.append(i)

ans = []

for j in range(1, n-1):
    count = 0
    l, r = set(S[:j]), set(S[j:])
    for k in l:
        if k in r:
            count += 1
    ans.append(count)

print(max(ans))

Solution (Python):
n=int(input())
hoge=input()
ans=[]
for i in  range(n-1):
  ho1=hoge[:i+1]
  ho2=hoge[i+1:]

  kari=0
  
  if(ho1.count("a") and ho2.count("a")):
    kari+=1
  if(ho1.count("b") and ho2.count("b")):
    kari+=1
  if(ho1.count("c") and ho2.count("c")):
    kari+=1
  if(ho1.count("d") and ho2.count("d")):
    kari+=1
  if(ho1.count("e") and ho2.count("e")):
    kari+=1
  if(ho1.count("f") and ho2.count("f")):
    kari+=1
  if(ho1.count("g") and ho2.count("g")):
    kari+=1
  if(ho1.count("h") and ho2.count("h")):
    kari+=1
  if(ho1.count("i") and ho2.count("i")):
    kari+=1
  if(ho1.count("j") and ho2.count("j")):
    kari+=1
  if(ho1.count("k") and ho2.count("k")):
    kari+=1
  if(ho1.count("l") and ho2.count("l")):
    kari+=1
  if(ho1.count("m") and ho2.count("m")):
    kari+=1
  if(ho1.count("n") and ho2.count("n")):
    kari+=1
  if(ho1.count("o") and ho2.count("o")):
    kari+=1
  if(ho1.count("p") and ho2.count("p")):
    kari+=1
  if(ho1.count("q") and ho2.count("q")):
    kari+=1
  if(ho1.count("r") and ho2.count("r")):
    kari+=1
  if(ho1.count("s") and ho2.count("s")):
    kari+=1
  if(ho1.count("t") and ho2.count("t")):
    kari+=1
  if(ho1.count("u") and ho2.count("u")):
    kari+=1
  if(ho1.count("v") and ho2.count("v")):
    kari+=1
  if(ho1.count("w") and ho2.count("w")):
    kari+=1
  if(ho1.count("x") and ho2.count("x")):
    kari+=1
  if(ho1.count("y") and ho2.count("y")):
    kari+=1
  if(ho1.count("z") and ho2.count("z")):
    kari+=1
    
  ans.append(kari)
  
print(max(ans))

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

Solution (Python):
import sys

def main():
  input = sys.stdin.readline
  N = int(input())
  S = str(input().strip())
  cur = 0
  for i in range(N):
    a, b = S[:i], S[i:]
    cur = max(cur, len(set(a) & set(b)))
  print(cur)


if __name__ == '__main__':
  main()

Solution (Python):
def main():
    N = int(input())
    S = input()
    ans = 0
    for i in range(1, N):
        X, Y = S[:i], S[i:]
        cnt = 0
        memo = []
        for letter in X:
            if letter not in memo:
                memo.append(letter)
                if letter in Y:
                    cnt += 1
        if cnt > ans:
            ans = cnt
    print(ans)


if __name__ == "__main__":
    main()

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

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

Solution (Python):



import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

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

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

Solution (Python):
input();a=input();print(max(len(set(a[:s])&set(a[s:]))for s in range(99)))

Solution (Python):
input();a=input();print(max(len(set(a[:s])&set(a[s:]))for s in range(99)))

Solution (Python):
input();a=input();print(max(len(set(a[:s])&set(a[s:]))for s in range(len(a))))

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

Solution (Python):
n,a=open(0).read().split();a,l=list(a),[]
for s in range(1,len(a)):l.append(len(set(a[:s])&set(a[s:])))
print(max(l))

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

ans = []

for i in range(N-1):
    x = 0
    for c in set(S[:i+1]):
        if c in set(S[i+1:]):
            x += 1
    ans.append(x)

print(max(ans))

Solution (Python):
def check(s1, s2):
    ss1 = set(s1)
    ss2 = set(s2)
    count = 0
    for si in ss1:
        if si in ss2:
            count += 1;
    return count


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

    mx = 0
    for i in range(1, len(s)):
        s1 = s[:i]
        s2 = s[i:]
        mx = max(check(s1, s2), mx)

    print(mx)


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
s = input()
ans = 0
for i in range(1,n-1):
    cnt = 0
    for j in set(s[:i]):
        if j in s[i:]:
            cnt += 1
    if cnt > ans:
        ans = cnt
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):
def main() -> None:
    N = int(input())
    S = input()
    m = 0
    for i in range(N):
        same_num = len(set(sorted(S[0:i])) & set(sorted(S[i:])))
        m = same_num if m < same_num else m
    
    print(m)


if __name__ == '__main__':
    main()

Solution (Python):
def main() -> None:
    N = int(input())
    S = input()
    m = 0
    for i in range(N):
        l1 = S[0:i]
        l2 = S[i:]
        if m < len(set(sorted(l1)) & set(sorted(l2))):
            m = len(set(sorted(l1)) & set(sorted(l2)))
    
    print(m)


if __name__ == '__main__':
    main()

Solution (Python):
def main() -> None:
    N = int(input())
    S = input()
    m = 0
    for i in range(len(S)):
        l1 = S[0:i]
        l2 = S[i:]
        if m < len(set(sorted(l1)) & set(sorted(l2))):
            m = len(set(sorted(l1)) & set(sorted(l2)))
    
    print(m)


if __name__ == '__main__':
    main()

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

count_max = 0
for i in range(n-1):
    mae = s[:i+1]
    ato = s[i+1:]
    count = 0
    for i in range(ord("a"), ord("z") + 1):
        if chr(i) in mae and chr(i) in ato:
            count += 1
    if count > count_max:
        count_max = count    

print(count_max)

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

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=input()
ans=0
for i in range(n):
    l = list(set(s[:i]))
    r = list(set(s[i:]))
    count=0
    for x in l:
        count+=r.count(x)
    if ans<count:
        ans=count
print(ans)

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

s=input()

count=0

for i in range(n-1):
    s1=s[:i+1]
    s2=s[i+1:]  
    seki=set(s1) & set(s2)
    if len(seki)>count:
        count=len(seki)

print(count)

Solution (Python):

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

def count_c(str1, str2):
    s1 = [0] * 26
    s2 = [0] * 26
    count = 0
    for i in list(str1):
        s1[ord(i) - 97] += 1
    for i in list(str2):
        s2[ord(i) - 97] += 1
    for i in range(26):
        if s1[i] > 0 and s2[i] > 0:
            count += 1
    return count
max_c = 0
for i in range(1,n):
    max_c = max(max_c, count_c(s[:i], s[i:]))
print(max_c)

Solution (Python):
int_n = int(input())
str_s = input()

result_ar = []
for i in range(len(str_s)):
    
    result_ar.append(len(set(str_s[:i]) & set(str_s[i:])))

print(max(result_ar))

Solution (Python):
n = int(input())
s = input()
ans = 0
for i in range(n):
    g = 0
    for j in set(s[:i]):
        if j in set(s[i:]):
            g += 1
    ans = max(ans,g)
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
  ans=max(ans,len(c))
print(ans)

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

for i in range(1,len(s)):
    count=set()
    x=s[0:i]
    y=s[i::]
    
    
    for j in range(len(x)):
        if x[j] in y:
            count.add(x[j])
    if max<len(count):
        max=len(count)

print(max)

Solution (Python):
N = int(input())
S = input()
group = set()
answer = 0

for x in range(0,N):
    number = 0
    for y in S[:x]:
        group.add(y)
    for y in S[x:]:
        if y in group:
            number += 1
            group.remove(y)
    answer = max(answer,number)
    group.clear 

print(answer)

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

ans = 0
num = len(S)

for i in range(num):
    X = set(S[:i + 1])
    Y = set(S[i + 1:num])
    ans = max(ans, len(X & Y))

print(ans)

Solution (Python):
n = int(input())
s = input()
l = []
if n==2:
    if s[0]==s[1]:
        print(1)
    else:
        print(0)
else:
    for i in range(1,len(s)-1):
        a = set(list(s[:i]))
        b = set(list(s[i:]))
        l.append(len(a & b))
    print(max(l))

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

print(max(a))

Solution (Python):
n=int(input())
s=input()
result=0
for i in range(n):
    x=s[0:i+1]
    y=s[i+1:]
    kind=0
    for j in range(len(x)):
        if x[j] in y:
            if x[j] in x[0:j]:
                pass
            else:
                kind+=1
    if kind>result:
        result=kind
print(result)

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

ans = 0
for i in range(N):
  cnt = 0
  l = list(set(S[:i]))
  r = list(set(S[i:]))
  for ll in l:
    if(ll in r):
      cnt += 1
  ans = max(ans, cnt)
print(ans)

Solution (Python):
n=int(input())
s=input()
count=0
ans=0
for i in range(1,n):
    a=set(s[:i])
    b=set(s[i:])
    for i in a:
        if i in b:
            count+=1
            if count>ans:
                ans=count
    count=0
print(ans)

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

S = input()

ma = 0
for i in range(1, N):
  a = S[i:]
  b = S[:i]
  cnt = 0
  a = list(set(a))
  for j in a:
    if j in b:
      cnt += 1
  if cnt > ma:
    ma = cnt

print(ma)

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

A = []

for i in range(1,N+1):
    ans = 0
    X = S[:i]
    Y = S[i:len(S)+1]
    L = []
    M = []
    for j in range(len(X)):
        L.append(X[j])
    for k in range(len(Y)):
        M.append(Y[k])
    LS = set(L)
    for l in LS:
         if l in M:
            ans += 1

    A.append(ans)

print(max(A))

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

count = []

if len(S) == 2:
    if S[0] == S[1]:
        count.append(1)
    else:
        count.append(0)
else:
    for i in range(1,N-1):
        sum = 0
        sita = S[0:i]
        usiro = S[i:N]

        
        sita = list(set(sita))
        usiro = list(set(usiro))

        
        for x in range(len(sita)):
            if sita[x] in usiro:
                sum += 1

        count.append(sum)

print(max(count))

Solution (Python):
n = int(input())
s = input()
mx = 0
for i in range(1,n):
  cnt = 0
  for j in range(ord('a'), ord('z')+1):
    c = chr(j)
    if c in s[0:i] and c in s[i:n]:
      cnt += 1
  mx = max(cnt, mx)
print(mx)

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

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

Solution (Python):


"""
Created on Mon Feb 11 05:38:56 2019

@author: shinjisu
"""



import math


def getInt(): return int(input())


def getIntList(): return [int(x) for x in input().split()]


def zeros(n): return [0]*n


def dmp(x):
    global debug
    if debug:
        print(x)


debug = True


def getIntLines(n): return [int(input()) for i in range(n)]


def getIntMat(n):
    mat = []
    for i in range(n):
        mat.append(getIntList())
    return mat


def zeros2(n, m): return [zeros(m)]*n


def prob096():  
    X = getIntList()
    K = getInt()
    dmp((X, K))
    total = sum(X) - max(X) + max(X)*2**K
    return total


def prob097():  
    X = getInt()
    dmp(X)
    if X == 1:
        return 1
    for n in range(X, 0, -1):
        dmp(n)
        for b in range(2, int(math.sqrt(X))+1):
            a = n
            exp = True
            while a > 1:
                if a % b != 0:
                    exp = False
                    break
                a //= b
            if exp:
                break
        if exp:
            break
    return n


def prob098():  
    N = getInt()
    S = input()
    dmp((N, S))
    maxChCount = 0
    for i in range(1, N):
        before = S[:i]
        after = S[i:]
        dmp((before, after))
        chCount = 0
        for j in range(26):
            ch = chr(ord('a')+j)
            if ch in before and ch in after:
                chCount += 1
        maxChCount = max(maxChCount, chCount)
    return maxChCount


debug = False  
print(prob098())

Solution (Python):
n = int(input())
s = str(input())
ans = 0
for i in range(1,len(s)):
    A = s[:i]
    B = s[i:]
    a = 0
    for l in range(len(A)):
        if A.find(A[l], l+1, ) != -1:
            continue
        for k in range(len(B)):
            if A[l] == B[k]:
                a += 1
                break
    if a > ans:
        ans = a
print(ans)

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

ans = 0
for i in range(1, N):
    S1s = Ss[:i]
    S2s = Ss[i:]
    num = 0
    for ch in 'abcdefghijklmnopqrstuvwxyz':
        if ch in S1s and ch in S2s:
            num += 1
    ans = max(ans, num)
print(ans)

Solution (Python):
input()
s = input().rstrip()
ans = 0
for i in range(1, len(s)):
    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):
    L = S[:i]
    R = S[i:]
    cnt = 0
    for s in set(L):
        if s in R:
            cnt += 1
    ans =max(ans,cnt)
print(ans)

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

Solution (Python):

import sys
from functools import reduce



def solve(lines):
    def func(n, i):
        a = set(S[:i])
        b = set(S[i:])
        return max( n, len(a & b) )

    N = int(lines.pop(0))
    S = lines.pop(0)

    print( reduce( func, range(1,N), 0 ) )




lines = [x.strip() for x in sys.stdin.readlines()]




solve(lines)

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

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

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

Solution (Python):
N = int(input())
S = str(input())
L = []
for i in range(N):
    S1 = S[0:i]
    S2 = S[i:]
    L.append(len(set(S1) & set(S2)))
print(max(L))

Solution (Python):


















import collections
def inpl(): return list(map(int, input().split()))


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

ans = 0
for i in range(1, N):
  aset = set(list(s[0:i]))
  bset = set(list(s[i:]))
  ta = len(aset & bset)
  if ta>ans:
    ans=ta

print(ans)

Solution (Python):
N = input()

S = list(raw_input())

ans = 0
for i in range(1,N):
    counter = 0
    X = S[0:i]
    Y = S[i:N]
    data = []
    for j in X:
        if j in Y and j not in data:
            counter += 1
            data.append(j)
    if ans < counter:
        ans = counter

print ans

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

Solution (Python):
def main():
    N = int(input())
    S = input()
    ans = 0
    for n in range(N + 1):
        c = 0
        for s in set(S[:n]):
            if S[n:].count(s) > 0:
                c += 1
        ans = max(ans, c)
    print(ans)


main()

Solution (Python):
def main():
    N = int(input())
    S = input()
    ans = 0
    for n in range(N + 1):
        c = 0
        u = []
        for s in S[:n]:
            if s in u:
                continue
            if S[n:].count(s) > 0:
                c += 1
            u.append(s)
        ans = max(ans, c)
    print(ans)


main()

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

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

print(ans)

Solution (Python):
N=int(input())
S=list(input())
X=[]
Y=[]
max_len=0
for i in range(N-1):
  X=S[:i+1]
  Y=S[i+1:]
  
  same_ele_num = len(set(X) & set(Y))
  
  if(same_ele_num > max_len):
    max_len = same_ele_num
print(max_len)

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

num = len(set(S))

result = 0
for i in range(N-1):
  A = S[:i+1]
  B = S[i+1:]
  
  tmp = len(set(A) & set(B))
  if tmp > result:
    result = tmp
  
print(result)

Solution (Python):
N = int(input())
S = input()
max_n = 0
for i in range(N):
  target1 = S[:i]
  target2 = S[i:]
  target1 = set(target1)
  target2 = set(target2)
  if max_n < len(target1 & target2):
    max_n = len(target1 & target2)
    
print(max_n)

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

num = len(set(S))

result = 0
for i in range(N-1):
  A = S[0:i+1]
  B = S[i+1:N]
  
  tmp = len(list(set(A) & set(B)))
  if tmp > result:
    result = tmp
  elif tmp == num:
    result = num
    break
  
print(result)

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

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

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

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

alphabet = 'abcdefghijklmnopqrstuvxwyz'
A = [0] * len(alphabet)
B = A.copy()


for c in s:
    pos = alphabet.find(c)
    A[pos]+=1




ans = 0
for c in s:
    pos = alphabet.find(c)
    A[pos] -= 1
    B[pos] += 1
    
    
    

    t = sum(1 if ae>0 and be > 0 else 0 for ae, be in zip(A,B) )

    ans = max(t,ans)

    

print(ans)

Solution (Python):
""" AtCoder """

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

w = "abcdefghijklmnopqrstuvwxyz"

count_max = 0

for i in range(N):
    count = 0
    for j in range(len(w)):
        if w[j] in S[:i] and w[j] in S[i:]:
            count += 1
    if count_max < count:
        count_max = count

print(count_max)

Solution (Python):
N = int(input())
S = input()
ret = 0
for n in range(1, N):
    a = set(S[:n])
    b = set(S[n:])
    tmp_ret = len([x for x in a if x in b])
    if ret < tmp_ret:
        ret = tmp_ret

print(ret)

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

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

print(ans)

Solution (Python):
from collections import Counter

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

res = 0
for i in range(1, N):
    c1 = Counter(s[:i])
    c2 = Counter(s[i:])
    res = max(res, len(set(c1.keys()) & set(c2.keys())))

print(res)

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

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

print(max(R))

Solution (Python):
N = int(input())
s = input()
max = 0
for i in range(N):
    count = 0
    s1 = s[:i]
    s2 = s[i:]
    A = set(s1)
    B = set(s2)
    for c in A:
        if c in B:
            count += 1
    if count > max:
        max = count
print(max)

Solution (Python):
def func(s1, s2):
    set1 = set(s1)
    set2 = set(s2)

    cnt = 0
    for _ in range(len(set1)):
        s = set1.pop()
        if s in set2:
            cnt += 1
    return cnt


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

    mx = 0
    for i in range(len(s) - 1):
        s1 = s[:i + 1]
        s2 = s[i + 1:]
        ans = func(s1, s2)
        if ans > mx:
            mx = ans

    print(mx)


if __name__ == '__main__':
    main()

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

print(a)

Solution (Python):
n = int(input())
s = input()
f = []
for i in range(n):
    a = []
    for j in range(i):
        if s[j] in s[i:]:
            a.append(s[j])
    f.append(len(set(a)))
print(max(f))

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

Solution (Python):
N = int(input())
S = input()
ans = 0
for i in range(1, N):
    X = S[:i]
    Y = S[i:]
    Xstr = []
    Ystr = []
    for j in range(len(X)):
        Xstr.append(X[j])
    for j in range(len(Y)):
        Ystr.append(Y[j])
    Xstr = list(set(Xstr))
    Ystr = list(set(Ystr))
    anstemp = 0
    for x in Xstr:
        if x in Ystr:
            anstemp += 1
    if ans < anstemp:
        ans = anstemp
print(ans)

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

print(n)

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

ans=0

for i in range(1,n):
  count = 0
  memo={}
  for j in range(i):
    if s[0:i][j] not in memo:
      if s[0:i][j] in s[i:n]:
        count += 1 
        memo[s[0:i][j]] = 1
  ans = max(count,ans)
  
print(ans)

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

ans = 0
for i in range(1, n):
    l= {}
    r= {}
    count = 0

    for c in range(0, i):
        l[s[c]] = True

    for c in range(i, n):
        r[s[c]] = True

    for c in l.keys():
        if r.get(c, False):
            count += 1
    ans = max(ans, count)

print(ans)

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

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

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

print(a)

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

print(a)

Solution (Python):
N = int(input())
S = input()
res = []
for i in range(1,N):
    X=S[:i]
    Y=S[i:]
    count = 0
    o=set()
    for j in X:
        
        if (not j in o) and j in Y:
            count+=1
            o.add(j)
    res.append(count)
print(max(res))

Solution (Python):


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

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

    print(r)


if __name__ == '__main__':
    main()

Solution (Python):
p=int(input())
a=input()
b=[]
for i in range(0,p):
    c=0
    t=list(set(a[:i]))
    k=a[i:]
    for j in range(len(t)):
        if t[j]in k:
            c+=1
    b.append(c)
print(max(b))

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

Solution (Python):
N = int(input())
S = list(input())
ans = []
for i in range(len(S)+1):
    num = 0
    X = S[:i]
    Y = S[i:]
    xd = {}
    yd = {}
    for j in X:
        if j in xd:
            continue
        else:
            xd[j] = 1

    for j in Y:
        if j in yd:
            continue
        else:
            yd[j] = 1


    for k in xd:
        if k in yd:
            num += 1

    ans.append(num)

print(max(ans))

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

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

print(ans)

Solution (Python):
n=int(input())
s=list(input())
a=[]
l=[]
for i in range(n):
  kind=0
  l.append(s.pop(0))
  for j in list(set(l)):
    if j in list(set(s)):
      kind+=1
  a.append(kind)
print(max(a))

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