//package com.company;/* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;


public class Main {
    public static int cGood(String str, char c){
        //System.out.println(str.length());
        if(str.length()==1){
            if(str.charAt(0)==c) return 0;
            else  return 1;
        }
        //System.out.println("Hello");
        int count1 =0, count2=0;
        int temp1=0, temp2=0;
        int c1=0, c2 =0;

        for(int i=0; i<str.length()/2; i++){
            if(str.charAt(i)!=c){
                c1++;
            }
        }
        count1 = c1+cGood(str.substring(str.length()/2, str.length()), (char)(c+1));

        for(int i=str.length()/2; i<str.length(); i++){
            if(str.charAt(i)!=c) c2++;
        }
        count2 = c2+cGood(str.substring(0, str.length()/2), (char)(c+1));
        return Math.min(count1, count2);
    }
    public static void main (String[] args) throws java.lang.Exception {
        FastReader sc = new FastReader();
        int testCase = sc.nextInt();
        while(testCase-->0){
            int n = sc.nextInt();
            String str = sc.nextLine();
            System.out.println(cGood(str, 'a'));
        }
    }
    // Fast Reader Class
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

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

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

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

