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

#define modulo 1000000007
#define N

void solve() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    if (n < 26) {
        cout << 0;
        return;
    }
    if (n == 26) {
        for (int i = 0; i < 26; i++) {
            if (s[i] != i + 'A') {
                cout << 0;
                return;
            }
        }
        cout << 1;
        return;
    }
    if (n == 27) {
        int index = -1;
        for (int i = 0; i < 27; i++) {
            if (s[i] != i + 'A' - (index >= 0)) {
                if (index == -1) {
                    index = i;
                    continue;
                }
                cout << 0;
                return;
            }
        }
        if (((index != 0?s[index - 1]:s[index]) == s[index]) || ((index != n - 1?s[index + 1]:s[index]) == s[index])) {
            cout << 2;
        }
        else
            cout << 1;
        return;
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}