// template halnix16


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

public class Main {


    static BufferedReader br;

    public static void main(String[] args) throws Exception {
        // write your code here
        br = new BufferedReader(new InputStreamReader(System.in));

        int t = (int) in();
        while (t-- > 0) {
            int n = (int) in();
           String s=  sin();

            System.out.println(ans('a',0,n-1,s,n));
        }

    }

    static long ans(char c,int si,int li,String s,int n){
        if(si==li){
            if(s.charAt(si)!=c){
                return 1;
            }return 0;
        }

        int f=0;
        int ff=0;
        int mid =n/2;
        int cc=0;
        for(int j =si;j<=li;j++,cc++){
            if(s.charAt(j)!=c){
                if(cc<mid){
                    f+=1;
                }else{
                    ff+=1;
                }
            }
        }
        long v = Math.min(f,ff);
if(f==ff) { v+=Math.min((ans((char)(c+1),si,(si+n/2)-1,s,n/2)) ,ans((char) (c+1),(si+n/2),li,s,n/2));} 
        if(f>ff){
            v+=ans((char)(c+1),si,(si+n/2)-1,s,n/2);
        }else{
if(f<ff) 
            v+=ans((char) (c+1),(si+n/2),li,s,n/2);
        }
        return v;


    }

    static long[] arr(long n) throws Exception {

        String read[] = sarrin();
        long arr[] = new long[(int) n];
        for (int k = 0; k < n; k++)
            arr[k] = in(read[k]);
        return arr;

    }

    static long[][] arr(long n, long m) throws Exception {


        long arr[][] = new long[(int) n][(int) m];
        for (int k = 0; k < n; k++) {
            String read[] = sarrin();
            for (int j = 0; j < m; j++)
                arr[k][j] = in(read[k]);
        }
        return arr;

    }

    static long in() throws Exception {
        return Long.parseLong(br.readLine());


    }

    static long in(String num) throws Exception {
        return Long.parseLong(num);


    }


    static String sin() throws Exception {

        return br.readLine();
    }

    static String[] sarrin() throws Exception {

        return br.readLine().split(" ");

    }

    static String[] regexSplit() throws Exception {
        return br.readLine().split(" ?(?<!\\G)((?<=[^\\p{Punct}])(?=\\p{Punct})|\\b) ?");
    }


}


class data {
    int fr;
    int f;
    int s;
}