#include <bits/stdc++.h>

using namespace std;

int minimumNumber(int n, string password) {
    // Return the minimum number of characters to make the password strong
  string  numbers = "0123456789";
string lower_case = "abcdefghijklmnopqrstuvwxyz";
string upper_case = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string special_characters = "!@#$%^&*()-+";
    int f=0,f1=0,f2=0,f3=0;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<numbers.length();j++)
        {
        if(password[i]==numbers[j]){
            f=1;
            break;
        }
        }
    }
     for(int i=0;i<n;i++)
    {
        for(int j=0;j<lower_case.length();j++)
        {
            
                if(password[i]==lower_case[j])
                {
                    f1=1;
                    break;
        }
     }
     }
     for(int i=0;i<n;i++)
    {
        for(int j=0;j<upper_case.length();j++)
        {
                    if(password[i]==upper_case[j]){
                        f2=1;
            break;
        }
        }
     }
     for(int i=0;i<n;i++)
    {
        for(int j=0;j<special_characters.length();j++)
        {
           if(password[i]==special_characters[j]){
               f3=1;
            break;
           }
        }
     }
  // cout<<f<<" "<<f1<<" "<<f2<<" "<<f3;
     int c=f+f1+f2+f3;
    if(password.length()<6)
    {
        c=4-c;
        int res = 6-password.length();
       // cout<<c<<" "<<res;
        if(res<c)
            return c;
        else
            return res;
        //return 0;
    }
        
   else
    return 4-c;
    }


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