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 Rust (1.15.1) (judge verdict: Accepted)

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

use std::collections::HashMap;

fn main() {
    input! {
        _n: usize,
        s: chars,
    }
    let mut called_time = Vec::new();
    for i in 1..s.len() {
        let mut m1 = (b'a'..b'z')
                    .map(|c| c as char)
                    .filter(|c| c.is_alphabetic())
                    .map(|c| (c, 0)).collect::<HashMap<_, _>>();
        m1.insert('z', 0);
        let mut m2 = (b'a'..b'z')
                    .map(|c| c as char)
                    .filter(|c| c.is_alphabetic())
                    .map(|c| (c, 0)).collect::<HashMap<_, _>>();
        m2.insert('z', 0);
        let mut v = (b'a'..b'z').map(|c| c as char).collect::<Vec<_>>();
        v.push('z');
        for j in 0..i {
            if let Some(x) = m1.get_mut(&s[j]) {
                *x += 1;
            }
        }
        for j in i..s.len() {
            if let Some(x) = m2.get_mut(&s[j]) {
                *x += 1;
            }
        }
        let mut time = 0;
        for j in 0..v.len() {
            if m2[&v[j]] != 0 && m1[&v[j]] != 0 {
                time+=1;
            }
        }
        called_time.push(time);
    }
    if let Some(x) = called_time.iter().max() {
        println!("{}", x);
    }
}