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 x) { int fl=1,fu=1,fd=1,fs=1,i=0; if(n<6){ for(i=0;i='a')&&(x.charAt(i)<='z')){ fl=0; continue; } else if((x.charAt(i)>='A')&&(x.charAt(i)<='Z')){ fu=0; continue; } else if((x.charAt(i)>='0')&&(x.charAt(i)<='9')){ fd=0; continue; } else{ fs=0; continue; } } int y=(6-n)>(fl+fu+fd+fs)?(6-n):(fl+fu+fd+fs); return y; } else{ for(i=0;i='a')&&(x.charAt(i)<='z')){ fl=0; continue; } else if((x.charAt(i)>='A')&&(x.charAt(i)<='Z')){ fu=0; continue; } else if((x.charAt(i)>='0')&&(x.charAt(i)<='9')){ fd=0; continue; } else{ fs=0; continue; } } return (fl+fu+fd+fs); } } 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(); } }