#!/bin/python3

import sys

def minimumNumber(n, password):
    numbers = set(list("0123456789"))
    lowercase = set(list("abcdefghijklmnopqrstuvwxyz"))
    upper = set(list("ABCDEFGHIJKLMNOPQRSTUVWXYZ"))
    special = set(list("!@#$%^&*()-+"))
   
    lf = 1
    nf = 1
    uf = 1
    sf = 1
    for i in password:
        
        if i in numbers and nf == 1:
            nf = 0
        if i in lowercase and lf == 1:
            lf = 0
        if i in upper and uf == 1:
            uf = 0
        if i in special and sf == 1:
            sf = 0
        
       # print(i, nf, sf, lf, uf)
        
        
        if sf == lf == nf == uf == 0:
            break
    
    if n < 6:
        len = 6 - n
        len -= (nf + sf + lf + uf)
        if len < 0:
            len = 0
    else:
        len = 0
        
    
    return len + (nf + sf + lf + uf)
            
    
    # Return the minimum number of characters to make the password strong

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