#include "bits/stdc++.h"
using namespace std;

int main() {
	int n, ans = INT_MIN, tmp = 0;
	bool alp[2][26] = { {0} };
	string s;
	cin >> n >> s;
	for (int i = 1; i < n; i++) {
		for (int j = 0; j < 26; j++) {
			if ((s.find('a' + j) < i) && (i <= s.rfind('a' + j)))tmp++;
		}
		ans = max(tmp, ans);
		tmp = 0;
	}
	cout << ans << "\n";
	return 0;
}