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 in Python (3.4.3) (judge verdict: Accepted)

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

slist=list(s)
maxlist=[]
for i in range(1,n):
    maximum=0
    sr=slist[:i]
    sl=slist[i:]
    if sr.count("a")!=0 and sl.count("a")!=0:
        maximum+=1
    if sr.count("b")!=0 and sl.count("b")!=0:
        maximum+=1
    if sr.count("c")!=0 and sl.count("c")!=0:
        maximum+=1
    if sr.count("d")!=0 and sl.count("d")!=0:
        maximum+=1
    if sr.count("e")!=0 and sl.count("e")!=0:
        maximum+=1
    if sr.count("f")!=0 and sl.count("f")!=0:
        maximum+=1
    if sr.count("g")!=0 and sl.count("g")!=0:
        maximum+=1
    if sr.count("h")!=0 and sl.count("h")!=0:
        maximum+=1
    if sr.count("i")!=0 and sl.count("i")!=0:
        maximum+=1
    if sr.count("j")!=0 and sl.count("j")!=0:
        maximum+=1
    if sr.count("k")!=0 and sl.count("k")!=0:
        maximum+=1
    if sr.count("l")!=0 and sl.count("l")!=0:
        maximum+=1
    if sr.count("m")!=0 and sl.count("m")!=0:
        maximum+=1
    if sr.count("n")!=0 and sl.count("n")!=0:
        maximum+=1
    if sr.count("o")!=0 and sl.count("o")!=0:
        maximum+=1
    if sr.count("p")!=0 and sl.count("p")!=0:
        maximum+=1
    if sr.count("q")!=0 and sl.count("q")!=0:
        maximum+=1
    if sr.count("r")!=0 and sl.count("r")!=0:
        maximum+=1
    if sr.count("s")!=0 and sl.count("s")!=0:
        maximum+=1
    if sr.count("t")!=0 and sl.count("t")!=0:
        maximum+=1
    if sr.count("u")!=0 and sl.count("u")!=0:
        maximum+=1
    if sr.count("v")!=0 and sl.count("v")!=0:
        maximum+=1
    if sr.count("w")!=0 and sl.count("w")!=0:
        maximum+=1
    if sr.count("x")!=0 and sl.count("x")!=0:
        maximum+=1
    if sr.count("y")!=0 and sl.count("y")!=0:
        maximum+=1
    if sr.count("z")!=0 and sl.count("z")!=0:
        maximum+=1
    maxlist.append(maximum)

print(max(maxlist))