import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class Solution {

    static int minimumNumber(int n, String password)
    {
        int i,constr=4;
        boolean flaga=true,flagA=true,flag1=true,flagspec=true;
        char ch;
        String spec="!@#$%^&*()-+";
        for(i=0;i<n;i++)
        {
            ch=password.charAt(i);
            if(flaga==true && (ch>='a' && ch<='z'))
            {
                flaga=false;
                constr--;
            }
            else if(flagA==true && (ch>='A' && ch<='Z'))
            {
                flagA=false;
                constr--;
            }
            else if(flag1==true && (ch>='0' && ch<='9'))
            {
                flag1=false;
                constr--;
            }
            else if(flagspec==true)
            {
                for(int j=0;j<spec.length();j++)
                {
                    if(ch==spec.charAt(j))
                    {
                        flagspec=false;
                        constr--;
                        break;
                    }
                }
            }
        }
        if(constr!=0 || n<6)
            return Math.max(constr,6-n);
        else
            return 0;
        
        
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        String password = in.next();
        int answer = minimumNumber(n, password);
        System.out.println(answer);
        in.close();
    }
}