
import java.io.*;
import java.util.*;
public class a8
{
	public static void main(String[] args)
	{
		Scanner sc =new Scanner(System.in);
		int t=sc.nextInt();
		while(t-- >0)
		{
			int n=sc.nextInt();
			String s=sc.next();
			System.out.println(countchar(s,0,s.length()-1,'a'));
		}
	}
	public static int countchar(String s,int beg,int last,char ch)
	{
		int mid=(last+beg)/2;int c1=0;int c2=0;
        if(beg>last)
          return 0;
      	if(beg==last)
        {
          if(ch==s.charAt(beg))
          {
            return 0;
          }
          else
          {
            return 1;
          }
        }
		for(int i=beg;i<=mid;i++)
		{
			if(s.charAt(i)!=ch)
				c1++;
		}
        for(int i=mid+1;i<=last;i++)
        {
          if(s.charAt(i)!=ch)
				c2++;
        }
		if(c1>c2)
		{
          	//System.out.println(c2+"@"+c1);
			return countchar(s,beg,mid,(char)(ch+1))+c2;
		}
		else
		{
            //System.out.println(c1+"@"+c2);
			return c1+countchar(s,mid+1,last,(char)(ch+1));
		}
		
	}
}