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) { boolean digit = false, upper = false, lower = false, symbol = false; int constraints = 0; for(char c : password.toCharArray()) { if(!digit && Character.isDigit(c)) { digit = true; constraints++; } else if(!upper && Character.isUpperCase(c)) { upper = true; constraints++; } else if(!lower && Character.isLowerCase(c)) { lower = true; constraints++; } else if (!symbol && isSymbol(c)) { symbol = true; constraints++; } } int answer = 0; if (constraints == 4) { if(n < 6) { answer = 6 - n; } } else { answer = 4 - constraints; if((answer + n) < 6) { answer += 6 - (answer + n); } } return answer; } public static boolean isSymbol(char c ) { return c == '!' || c == '@' || c == '#' || c == '$' || c == '%' || c == '^' || c == '&' || c == '(' || c == ')' || c == '-' || c == '+'; } 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(); } }