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) { // Return the minimum number of characters to make the password strong String []numbers = {"0","1","2","3","4","5","6","7","8","9"}; String []lower_case = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"}; String []upper_case = {"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"}; String [] special_characters = {"!","@","#","$","%","^","&","*","(",")","-","+"}; boolean hasLowerCase = stringContainsItemFromList(password, lower_case); boolean hasUpperCase = stringContainsItemFromList(password, upper_case); boolean hasNumber = stringContainsItemFromList(password, numbers); boolean hasSpecial = stringContainsItemFromList(password, special_characters); if(n>=6){ //length is okay if(hasLowerCase&&hasNumber&&hasSpecial&&hasUpperCase){ return 0; } else if(!hasLowerCase&&hasNumber&&hasSpecial&&hasUpperCase){ return 1; } else if(hasLowerCase&&!hasNumber&&hasSpecial&&hasUpperCase){ return 1; } else if(hasLowerCase&&hasNumber&&!hasSpecial&&hasUpperCase){ return 1; } else if(hasLowerCase&&hasNumber&&hasSpecial&&!hasUpperCase){ return 1; } else if(!hasLowerCase&&!hasNumber&&hasSpecial&&hasUpperCase){ return 2; } else if(hasLowerCase&&!hasNumber&&!hasSpecial&&hasUpperCase){ return 2; } else if(hasLowerCase&&hasNumber&&!hasSpecial&&!hasUpperCase){ return 2; } else if(!hasLowerCase&&hasNumber&&!hasSpecial&&hasUpperCase){ return 2; } else if(hasLowerCase&&!hasNumber&&hasSpecial&&!hasUpperCase){ return 2; } else if(!hasLowerCase&&!hasNumber&&!hasSpecial&&hasUpperCase){ return 3; } else if(hasLowerCase&&!hasNumber&&!hasSpecial&&!hasUpperCase){ return 3; } else if(!hasLowerCase&&!hasNumber&&hasSpecial&&!hasUpperCase){ return 3; } else if(!hasLowerCase&&!hasNumber&&!hasSpecial&&!hasUpperCase){ return 4; } } else if(n<6){ //length is short return 6-n; } } public static boolean stringContainsItemFromList(String inputStr, String[] items) { for(int i =0; i < items.length; i++) { if(inputStr.contains(items[i])) { return true; } } return false; } 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(); } }