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) { /* numbers = "0123456789" lower_case = "abcdefghijklmnopqrstuvwxyz" upper_case = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" special_characters = "!@#$%^&*()-+" */ int counter = 0; String regexNs = ".*[0-9]+.*"; Pattern regexNsP = Pattern.compile(regexNs); Matcher m = regexNsP.matcher(password); if (!m.find()) counter++; String regexLC = ".*[a-z]+.*"; Pattern regexLCP = Pattern.compile(regexLC); m = regexLCP.matcher(password); if (!m.find()) counter++; String regexUC = ".*[A-Z]+.*"; Pattern regexUCP = Pattern.compile(regexUC); m = regexUCP.matcher(password); if (!m.find()) counter++; String regexSC = ".*[\\!\\@\\#\\$\\%\\^\\&\\*\\(\\)\\-\\+]+.*"; Pattern regexSCP = Pattern.compile(regexSC); m = regexSCP.matcher(password); if (!m.find()) counter++; if (n+counter < 6) { counter+=6-n-counter; } return counter; } 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(); } }