#include <bits/stdc++.h>

using namespace std;

int minimumNumber(int n, string password) {
    // Return the minimum number of characters to make the password strong
    bool lc=false,uc=false,sp=false,nb=false;
    
    map<char,bool> mp;
    mp['!'] = 1;
    mp['@'] = 1;
    mp['#'] = 1;
    mp['$'] = 1;
    mp['%'] = 1;
    mp['^'] = 1;
    mp['&'] = 1;
    mp['*'] = 1;
    mp['('] = 1;
    mp[')'] = 1;
    mp['-'] = 1;
    mp['+'] = 1;
    for(int i=0;i<n;i++){
        if(password[i]>='0' && password[i]<='9') nb = 1;
        if(password[i]>='a' && password[i]<='z') lc = 1;
        if(password[i]>='A' && password[i]<='Z') uc = 1; 
        if(mp[password[i]]==1) sp = 1;
    }
    int req = 0;
    if(!nb) req++;
    if(!lc) req++;
    if(!uc) req++;
    if(!sp) req++;
    if(n+req<6) req = 6-n;
    return req;
}

int main() {
    int n;
    cin >> n;
    string password;
    cin >> password;
    int answer = minimumNumber(n, password);
    cout << answer << endl;
    return 0;
}