import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static int MAX = 4; static int minimumNumber(int n, String password) { int found =0; boolean number = false; boolean lower = false; boolean upper = false; boolean special = false; for(char c : password.toCharArray()) { int a = c; if(found == 4 ){ break; } if(!number) { if(a >= 48 && a <= 57) { number = true; ++found; continue; } } if(!lower) { if(a >= 97 && a <= 122) { lower = true; ++found; continue; } } if(!upper) { if(a >= 65 && a <= 90) { upper = true; ++found; continue; } } if(!special) { if(a == 33 || a ==45 || a == 64 ||(a >= 35 && a <=38) || a == 94 || (a >=40 && a <=43)) { special = true; ++found; } } } int diff = 0; if(password.length() <6){ diff = 6 - password.length(); } return Math.max(MAX - found,diff); } 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(); } }