#include <iostream>
#include <string>
using namespace std;
int main()
{
	int N, brojac1 = 0, brojac2 = 0;
	cin >> N;
	string a, pomocni = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	cin >> a;
	if (N <= 25)
	{
		cout << 0;
	}
	else if (N == 26)
	{
		if (a == pomocni) cout << 1;
		else cout << 0;
	}
	else if (N == 27)
	{
		for (int i = 0; i < N-1; i++)
		{
			if ((a[i] != pomocni[i]) && (a[i + 1] != pomocni[i]))
			{
				brojac1++;
			}
			if (a[i] == a[i + 1])
			{
				brojac2++;
			}
		}
		if (brojac1 != 0) cout << 0;
		else if (brojac2 == 0) cout << 1;
		else cout << 2;
	}
}