import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashSet;
import java.util.StringTokenizer;
public class Main{
    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        String next() {
            while (!st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] nextArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }
        long[] nextArray(long n) {
            long[] a = new long[(int) n];
            for (int i = 0; i < n; i++) a[i] = nextLong();
            return a;
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
    static class FastWriter extends PrintWriter {
            FastWriter(){
                super(System.out);
            }
            void println(int[] array) {
                for(int i=0; i<array.length; i++) {
                    print(array[i]+" ");
                }
                println();
            }
            void println(long [] array) {
                for(int i=0; i<array.length; i++) {
                    print(array[i]+" ");
                }
                println();
            }
        }
    public static void main(String[] args){
        FastScanner in = new FastScanner();
        FastWriter out = new FastWriter();
        int t=in.nextInt();
        outer:while (t-->0) {
            int n=in.nextInt();
            String str=in.next();
            out.println(check(str,'a',0,n));
        }
        out.close();
    }
    public static int check(String str,char ch,int i,int j){
        if((j-i)==1){
            if(str.charAt(i)==ch){
                return 0;
            }else{
                return 1;
            }
        }
        int cnt1=0,cnt2=0;
        for (int k = i; k < (j+i)/2; k++) {
            if(str.charAt(k)!=ch){
                cnt1++;
            }
        }
        for (int k = (i+j)/2; k < j; k++) {
            if(str.charAt(k)!=ch){
                cnt2++;
            }
        }
        if(cnt1<cnt2){
            return cnt1+check(str,(char)(ch+1),(i+j)/2,j);
        }else if(cnt1>cnt2){
            return cnt2+check(str,(char)(ch+1),i,(i+j)/2);
        }else{
            return Math.min(cnt1+check(str,(char)(ch+1),(i+j)/2,j),cnt2+check(str,(char)(ch+1),i,(i+j)/2));
        }
    }
}