#include <bits/stdc++.h>

using namespace std;

string special_characters = "!@#$%^&*()-+";

static bool isspecial (char c)
{
    for (char spl : special_characters)
    {
        if (spl == c) return true;
    }
    return false;
}

int minimumNumber(int n, string password) {
    // Return the minimum number of characters to make the password strong
    int ret = 0;
    int intP = 1, lowc=1, upc=1, splc=1;
    
    for (int idx = 0; idx <= n; idx ++)
    {
        if (isdigit(password[idx])) {intP = 0;}//cout << "digit\n";}
        else if (islower(password[idx])) {lowc = 0;}//cout << "lower\n";}
        else if (isupper(password[idx]))  {upc = 0;}//cout << "upper\n";}
        else if (isspecial(password[idx])) {splc = 0;}//cout << "spl\n";}
    }
    
    ret = intP+lowc+upc+splc;
 //   cout << "ret = " << ret << endl;
    return (n+ret < 6)? (6-n): ret;
}

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