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 int length = password.length(); int testcase1 = 0, testcase2 = 0, testcase3 = 0, testcase4 = 0; for(int i = 0; i < length; i++){ char ch = password.charAt(i); if(Character.isUpperCase(ch)){ testcase1 = 1; } else if(Character.isLowerCase(ch)){ testcase2 = 1; } else if(Character.isDigit(ch)){ testcase3 = 1; } else{ testcase4 = 1; } } int condition = testcase1 + testcase2 + testcase3 + testcase4; //System.out.println(testcase2); if(condition == 4){ if(length < 6){ return (6 - length); } else{ return 0; } } else{ if(length >= 6){ return (4 - condition); } else{ int remainingLength = 6 - length; int remainingCondition = 4 - condition; if(remainingLength <= remainingCondition){ return remainingCondition; } else{ return remainingLength; } } } } 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(); } }