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

public class main{
    static Read input  = new Read();
    static String all;

    static int good(char a,int s,int e){

        if (e-s==1){
            return all.charAt(s)==a? 0:1;
        }

        int l=0,r=0;

        for (int i=s;i<(s+e)/2;i++) if (all.charAt(i)!=a) l++;
        for (int i=(s+e)/2;i<e;i++) if (all.charAt(i)!=a) r++;

        if (l<r)
            return l+good((char)(a+1),(s+e)/2,e);
        else if (r<l)
            return r+good((char)(a+1),s,(s+e)/2);
        else 
            return Math.min(l+good((char)(a+1),(s+e)/2,e),r+good((char)(a+1),s,(s+e)/2));
    }

    static void solve(){

        int n = input.nextInt();
        all = input.next();

        int ans = good('a',0,n);
        System.out.println(ans);

    }

    public static void main(String args[]){
        
        int t = input.nextInt();
        while (t-->0)
            solve();

    }

    static class Read{
        BufferedReader br;
        StringTokenizer st;
        public Read(){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());}
        double nextDouble(){return Double.parseDouble(next());}
        long nextLong(){return Long.parseLong(next());}
        String line(){
            String ans="";
            try {ans = br.readLine(); }
            catch(IOException e) {e.printStackTrace(); }
            return ans;
        }
    }

}