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 JavaScript (node.js v5.12) (judge verdict: Accepted)

const BKRT = "\n";
const SPAC = " ";
const NOSP = "";



function Main(input){
	input = [].concat(...input.trim().split(BKRT).map(a=>a.split(SPAC)));
  const strShift = ()=>input.shift();
  const intShift = ()=>~~input.shift();
  
  var N = intShift();
  var S = strShift();
  
  var o = [];
  
  for(var j = 1; j < N; j++){
  	var bef = Array.from({length:26},()=>false);
  	var aft = Array.from({length:26},()=>false);
  	for(var i = 0; i < j;i++){
  		var t = parseInt(S[i],36)-10;
      bef[t]=true;
  	}
    for(var i = j; i < N;i++){
    	var t = parseInt(S[i],36)-10;
      aft[t]=bef[t];
    }
    o.push(aft.filter(a=>a).length);
  }
  
  return ~~Math.max(...o);
}

// If you are interested in the algorithms I used, 
// there is no need to read down from this line.

((b,c,d)=>"undefined"!=typeof require?console.log(Main(require("fs").readFileSync("/dev/stdin","utf8"))):[b=b.split("\n").slice(1,-1).join("\n"),c=function(){try{return Main(b)}catch(f){return f.stack||f.message}}(),d=typeof c,"string"==d||(c=JSON.stringify(c)),$("<form>").append([[10,b],0,[1,d],0,[10,c]].map(f=>$(f?"<textarea>":"<br>",f&&{rows:f[0],cols:40,text:f[1]}))).appendTo("body")])(`
45
tgxgdqkyjzhyputjjtllptdfxocrylqfqjynmfbfucbir
`);