#include <iostream>
#include <bits/stdc++.h>
using namespace std;

bool isSubstring(string s1, string s2){
    int br = 0;
    for(int i = 0; i < s1.length(); i++)
        if(s1[i] != 'A' + i - br)
            br++;
    if (br >= 2)
        return false;
    return true;
}

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    if (s == "ABCDEFGHIJKLMNOPQRSTUVWXYZ"){
        cout << 1;
        return 0;
    }
    if(n <= 26){
        cout << 0;
        return 0;
    }
    int ans = 0;
    if(n == 27){
        if(isSubstring(s, "ABCDEFGHIJKLMNOPQRSTUVWXYZ")){
        for(int i = 0; i < n; i++){
            if(s[i] == s[i - 1] || s[i] == s[i + 1]){
                cout << 2;
                ans++;
                i = n;
            }
            }
            if (ans == 0)
                cout << 1;
        }
        else
            cout << "0";
    }
    return 0;
}