#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define FOR(n) for(int i = 0; i < n; i++)
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<long long, long long>
#define pdd pair<double, double>
#define mii map<int,int>
#define C const int
using namespace std;

int malo(int n, char a[], mii m){
    if(n<26) {
        cout << "0\n";
        return 0;
    }
    FOR(26){
        if(m[i]==0) {
            cout << "0\n";
            return 0;
        }
    }

    if(n==26){
        FOR(n-1){
            if(a[i]-'A' > a[i+1]-'A') {
                cout << "0\n";
                return 0;
            }
        }
        cout << "1\n";
        return 0;
    }
    if(n==27){
        bool izbacen = false;
        FOR(26){
            if(a[i]-'A' >= a[i+1]-'A'){
                if(izbacen){
                    cout << "0\n";
                    return 0;
                }
                izbacen = true;
                i++;
            }
            cout << "1\n";
            return 0;
        }
    }
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

    int n; cin >> n;
    string s; cin >> s;
    C mxn = 1e6, MOD = 1e9 + 7;
    char a[mxn];
    mii m;
    FOR(n){
        a[i]=s[i];
        m[s[i]-'A']++;
    }


    if(n<=27) {malo(n,a,m);return 0;}



}