#!/bin/python3

import sys

def minimumNumber(no, password):
    # Return the minimum number of characters to make the password strong
    numbers = "0123456789"
    lower_case = "abcdefghijklmnopqrstuvwxyz"
    upper_case = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    special_characters = "!@#$%^&*()-+"
    n = False
    lc = False
    uc = False
    sc = False
    r_l = 0
    
    max_letters = 6
    l = [x for x in password]
   
    
    if( no >= max_letters or no<max_letters):
        for i in l:
            if(n==True and lc == True and uc == True and sc == True):
                r_l = 0
                break;
            elif i in numbers:
                n = True
            elif i in lower_case:
                lc = True
            elif i in upper_case:
                uc = True
            elif i in special_characters:
                sc = True
            else:
                pass
        l = [n,lc,uc,sc]
        r_l = l.count(False) 
     
    if(no<max_letters):
        rem_l = max_letters - len(password)
        if(r_l < rem_l):
            r_l = rem_l
            
           
                
   # else:
   #     r_l = max_letters-len(password);
    
    return r_l
        
        
    

if __name__ == "__main__":
    n = int(input().strip())
    password = input().strip()
    answer = minimumNumber(n, password)
    print(answer)