import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;
public class Cf
{
public static int getcount(int l,int h,char c,String s)
{
	int c1=0;
	for(int j=l;j<=h;j++)
	{
		if(Character.compare(c,s.charAt(j))!=0)
		{
			c1=c1+1;
		}
	}
	return c1;
}
public static int min(int d,int e)
{
	if(d<e)
			return d;
		else
			return e;
}
public static int getmin(int l,int h,char c,String s)
{
	if(l==h)
	{
		if(Character.compare(c,s.charAt(h))==0)
		{
			
			return 0;
		}
		else
		{

			return 1;
		}
	}
	else
	{
		int mid=(l+h)/2;
		
		int d=(int)c;
		char c3=(char)(d+1);
		return min(getcount(l,mid,c,s)+getmin(mid+1,h,c3,s),getcount(mid+1,h,c,s)+getmin(l,mid,c3,s));
	}
}

	public static void main(String args[])
	{
		
		Scanner sc=new Scanner(System.in);
		int t=sc.nextInt();
		for(int i=0;i<t;i++)
		{
		int l1=sc.nextInt();
		String s=sc.next();
		System.out.println(getmin(0,l1-1,'a',s));
		}
		
}
}