#include <bits/stdc++.h>

using namespace std;

int minimumNumber(int n, string password) {
    // Return the minimum number of characters to make the password strong
    const int minLength = 6;
    bool number = false;
    bool lowerCase = false;
    bool upperCase = false;
    bool symbol = false;
    int length = password.length();
    int result = 0;
    
    for(int i = 0; i < length; i++){
        if(password[i] >= '0' && password[i] <= '9'){
            number = true;
        }else if(password[i] >= 'a' && password[i] <= 'z'){
            lowerCase = true;
        }else if (password[i] >= 'A' && password[i] <= 'Z'){
            upperCase = true;
        }else{
            symbol = true;
        }
    }
    
    if(number != true){
        result++;
        length++;
    }
    
    if(lowerCase != true){
        result++;
        length++;
    }
    
    if(upperCase != true){
        result++;
        length++;
    }
    
    if(symbol != true){
        result++;
        length++;
    }
    
    if(length < minLength){
        result += minLength - length;
    }
    
    return result;
}

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