import java.util.*;

public class password
{
	public static void main(String args[])
	{
		Scanner ob=new Scanner(System.in);
		int n=ob.nextInt();
		String s=ob.next();
		char[] c=s.toCharArray();
		int[] a=new int[n];
		int c1=0;
		boolean x=true;
		boolean y=true;
		boolean z=true;
		boolean w=true;
		for(int i=0;i<n;i++)
		{
			a[i]=(int)c[i];
		}
		if(n<=3)
		{
			int r=6-n;
			System.out.println(r);
		}
		else
		{
			for(int j=0;j<n;j++)
			{
				if(x==true && a[j]>=48 && a[j]<=57)
				{
					c1++;
					x=false;
				}
				else if(y==true && a[j]>=65 && a[j]<=90)
				{
					c1++;
					y=false;
				}
				else if(z==true && a[j]>=97 && a[j]<=122)
				{
					c1++;
					z=false;
				}
				else if(w==true && (a[j]==33 || a[j]==45 || a[j]==64 || a[j]==94 || (a[j]>=35 && a[j]<=38) || (a[j]>=40 && a[j]<=43)))
				{
					c1++;
					w=false;
				}
			}
			if(c1==1)
			{
				System.out.println("3");
			}
			if(c1==2)
			{
				System.out.println("2");
			}
			if(c1==3)
			{
				if(n==4)
				{
					System.out.println("2");
				}
				else
					System.out.println("1");
			}
			if(c1==4)
			{
				if(n==4)
				{
					System.out.println("2");
				}
				else if(n==5)
					System.out.println("1");
				else
					System.out.println("0");
			}
		}
	}
}