#include <bits/stdc++.h>

using namespace std;

int minimumNumber(int n, string password) {
string numbers= "0123456789"; 
string lower_case= "abcdefghijklmnopqrstuvwxyz";
string  upper_case= "ABCDEFGHIJKLMNOPQRSTUVWXYZ";  
string  special_characters = "!@#$%^&*()-+";
    int dig=0,small=0,lar=0,spe=0;
        for(int j=0;j<password.length();j++){
            for(int i=0;i<numbers.length();i++){
                if(password[j]==numbers[i]){
                    dig=1;
                    break;
                }
        }
    }
            for(int j=0;j<password.length();j++){
            for(int i=0;i<lower_case.length();i++){
                if(password[j]==lower_case[i]){
                    small=1;
                    break;
                }
        }
    }
            for(int j=0;j<password.length();j++){
            for(int i=0;i<upper_case.length();i++){
                if(password[j]==upper_case[i]){
                    lar=1;
                    break;
                }
        }
    }
    for(int j=0;j<password.length();j++){
        if(password[j]=='!'||password[j]=='@'||password[j]=='#'||password[j]=='$'||password[j]=='%'||password[j]=='^'||password[j]=='&'||password[j]=='*'||password[j]=='('||password[j]==')'||password[j]=='-'||password[j]=='+'){
            spe=1;
            break;
        }
    }
    int count=small+lar+spe+dig;
    if(password.length()>=6){
        return 4-count;
    }
    else if(password.length()<=2){
        return (6-password.length());
    }
    else if(password.length()>2 && password.length()<6){
        if(count==0){
            return 4;
        }
        if(count==1){
            return 3;
        }
        if(count==2){
            if((6-password.length())>=2){
            return 6-password.length();}
            else{
                return 2;
            }
        }          

          if(count==4 ||count==3){
            return 6-password.length();
        }
    }
    return 0;
}

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