#include <iostream>
#include <string>

using namespace std;

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    if(n < 26){
        cout << 0;
    }
    else if(n == 26){
        if(s == "ABCDEFGHIJKLMNOPQRSTUVWXYZ")
            cout << 1;
        else
            cout << 0;
    }
    else{
        bool nemoguce = false;
        int asci = 65;
        bool duplo = false;
        for(int i = 0; i < 26; i++){
            if(s[i] != i + asci){
                if(nemoguce){
                    cout << 0;
                    nemoguce = false;
                    break;
                }
                else{
                    nemoguce = true;
                    asci--;
                    if(s[i] == s[i - 1])
                        duplo = true;
                }
            }
        }
        if(nemoguce){
            if(duplo) cout << 2;
            else cout << 1;
        }
    }
    return 0;
}