//package test;
import java.io.*;
import java.util.*;

public class Problem1385D {
    private static char[] mask=new char[]{'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
    
    static int f(int m,String s,int l)
    {
        int move=0;
        if(l==1)
        {
            if(s.charAt(0)==mask[m])
                return 0;
            else
                return 1;
        }
        else
        {
            char x=mask[m];
            String temp="";
            int c1=0;int c2=0;
            int tp=0;
            for(int i=0;i<l/2;i++)
            {
                if(s.charAt(i)==x)
                    c1+=1;
            }
            for(int i=l/2;i<l;i++)
            {
                if(s.charAt(i)==x)
                    c2+=1;
            }
            if(c1>=c2)
            {
                tp=l/2-c1;
                temp=s.substring(l/2,l);
            }
            else
            {
                tp=l/2-c2;
                temp=s.substring(0, l/2);
            }
            move=tp+f(m+1,temp,l/2);
        }
        return move;
    }
    
    public static void main(String[] args) throws IOException
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int t=Integer.parseInt(br.readLine());
        for(int i=0;i<t;i++)
        {
            int n=Integer.parseInt(br.readLine());
            String s=br.readLine();
            System.out.println(f(0,s,n));
        }
    }
}
