#!/bin/python3 import sys def minimumNumber(n, password): num,l,u,c = 1,1,1,1 numbers = "0123456789" lower_case = "abcdefghijklmnopqrstuvwxyz" upper_case = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" special_characters = "!@#$%^&*()-+" for i in range(n): if(password[i] in numbers and num==1): num = 0 if(password[i] in lower_case and l==1): l = 0 if(password[i] in upper_case and u==1): u = 0 if(password[i] in special_characters and c==1): c = 0 if(num==0 and l==0 and u==0 and c==0): break ans = num+l+u+c if (n>6 or n+ans>6): return ans else: return 6-n if __name__ == "__main__": n = int(input().strip()) password = input().strip() answer = minimumNumber(n, password) print(answer)