/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
    static String s="";
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner in=new Scanner(System.in);
		int t=in.nextInt();
		while(t--!=0)
		{
		    int n=in.nextInt();
		    s=in.next();
		    Codechef obj=new Codechef();
		    int q=obj.f(0,n,'a');
		    System.out.println(q);
		}
	}
	int f(int l,int r,char c)
	{
	    if(r-l==1)
	    {
	        if(s.charAt(l)==c)
	        return 0;
	        else
	        return 1;
	    }
	    int p1=0;
	    int p=0;
	    for(int i=l;i<r;i++)
	    {
	        if(s.charAt(i)==c && i<(l+r)/2)
	        p++;
	        else if(s.charAt(i)==c && i>=(l+r)/2)
	        p1++;
	    }
	    return Math.min(f(l,(l+r)/2,(char)((int)c+1))+(r-l)/2-p1,f((l+r)/2,r,(char)((int)c+1))+(r-l)/2-p);
	}
}
