#include <bits/stdc++.h>

using namespace std;

int minimumNumber(int n, string s) {
    // Return the minimum number of characters to make the password strong
    int a=0,b=0,c=0,d=0;
    int ans=0;
    string k="!@#$%^&*()-+";
    for(int i=0;i<n;i++){
        if(s[i]-'a'>=0&&s[i]-'a'<26){
            a=1;
        }
        else if(s[i]-'A'>=0&&s[i]-'A'<26){
            b=1;
        }
        else if(s[i] >=48&&s[i]<=57){
            c=1;
        }
        else{
            if(d) continue;
            
            for(int j=0;j<k.length();j++){
                if(s[i]==k[j]){
                    d=1;
                    break;
                }
            }            
        }
    }
    if(a==0) ans++;
    if(d==0) ans++;
    if(c==0) ans++;
    if(b==0) ans++;
   //if(n + ans >=6) return ans;
    return max((6-n),ans);
}

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