import java.util.*;
import java.io.*;
import java.lang.*;
public class Main{
     static class FastReader{
	BufferedReader br;
	StringTokenizer st;
      public FastReader(){
         br=new BufferedReader(new InputStreamReader(System.in));
         }
      public FastReader(String s)throws FileNotFoundException{
        br=new BufferedReader(new FileReader(new File(s)));
        }
       String next(){
          while(st==null || !st.hasMoreElements()){
            try{
                  st=new StringTokenizer(br.readLine());
                  }
            catch(IOException e){
                   e.printStackTrace();
		}

               }
             return st.nextToken();
         }
        String nextLine(){
             String str="";
             try{
                 str=br.readLine();
                 }
            catch(IOException e){
              e.printStackTrace();
                     }
                return str;
           }
	int nextInt(){
            return Integer.parseInt(next());
                }
         long nextLong(){
            return Long.parseLong(next());
             }
         double nextDouble(){
            return Double.parseDouble(next());

            }
  } 
  public static int minposs(String s,char c){
         int k=s.length()/2;
         if(s.length()==1){
               if(s.charAt(0)==c)
                 return 0;
               else return 1;
         
         }
         int rc=0,lc=0;
       int n=s.length();
       for(int i=0;i<k;i++)
          if(s.charAt(i)==c)
             rc++;
        for(int i=k;i<n;i++)
          if(s.charAt(i)==c)
             lc++;
        lc=k-lc;
        rc=k-rc;
       int right=minposs(s.substring(k),(char)((int)c+1));
       int rightr=minposs(s.substring(0,k),(char)((int)c+1));
       return Math.min(rc+right,lc+rightr);
  
  } 
  	public static void main(String[] args)throws IOException {
	     FastReader in=new FastReader();
            int T=in.nextInt();
            while(T-->0){
              int n=in.nextInt();
              String s=in.next();
              System.out.println(minposs(s,'a'));
           }
      }
}		

