#include<stdio.h> 
#include <iostream>
#include <algorithm>
#include<string>
#include<string.h>
#include<math.h>
/****  STL  ****/
#include<vector>
#include<queue>
#include<unordered_map>
#include<unordered_set>

#define uint unsigned int
#define ll long long
#define kMin -1
using namespace std;

const int kMax = 1600;
const int kInf = 1e9;

int a[30], ax = 0;
int b[30], bx = 0;
char cs[105];
int  main()
{
	int n;
	while (cin >> n)
	{
		memset(a, 0, sizeof(a));
		memset(b, 0, sizeof(b));
		ax = 0;
		bx = 0;

		char c;
		for (int i = 0; i < n; i++)
		{
			cin >> c;
			cs[i] = c;
			if (b[c - 'a'] == 0)
			{
				bx++;
			}
			b[c - 'a']++;
		}
		int maxx = -1;
		for (int i = 0; i < n - 1; i++)
		{
			b[cs[i] - 'a']--;
			if (a[cs[i] - 'a'] == 0)ax++;
			if (b[cs[i] - 'a'] == 0)
			{
				ax--;
				if (ax < 0)ax = 0;
			}
			a[cs[i] - 'a']++;

			maxx = max(maxx, ax);
		}
		cout << maxx << endl;
	}
	return 0;
}