#include <bits/stdc++.h>

using namespace std;
const char *special_characters = "!@#$%^&*()-+";

int minimumNumber(int n, string password) {
    // Return the minimum number of characters to make the password strong
    int digit=1, lowcase =1, upcase = 1, special =1;
    int len=password.length();
    for(int i=0; i<len; ++i){
        if(isdigit(password[i])&&digit>0)--digit;
        else if(password[i]>='a'&&password[i]<='z'&&lowcase>0)--lowcase;
        else if(password[i]>='A'&&password[i]<='Z'&&upcase>0)--upcase;
        else if(strchr(special_characters, password[i])!=NULL&&special>0)--special;
    }
    return max(digit+lowcase+upcase+special, 6-len);
}

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