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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int x; cin >> x;
    string n; cin >> n;
    int res;
    if (n.size() <= 26) cout << 0;
    else if (n.size() == 27) {
        int p1, p2;

        for (int i = 0; i < n.size(); ++i) {
            char current = n[i];
            for (int j = i+1; j < n.size(); ++j) {
                if (n[j] == current) {
                    p1 = i; p2 = j; goto nastavi;
                }
            }
        }

        nastavi:;
        if (abs(p2-p1) == 1) res = 2;
        else res = 1;

        string news = n.substr(0,p1) + n.substr(p1+1, n.size()-p1+1);
        string news2 = n.substr(0,p2) + n.substr(p2+1, n.size());
        //cout << news << endl;
        if (news == "ABCDEFGHIJKLMNOPQRSTUVWXYZ" || news2 == "ABCDEFGHIJKLMNOPQRSTUVWXYZ") cout << res;
        else cout << 0;
    }


    return 0;
}