

import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;

public class Main
{
    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String n() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int ni() 
        { 
            return Integer.parseInt(n()); 
        } 
  
        long nl() 
        { 
            return Long.parseLong(n()); 
        } 
  
        double nd() 
        { 
            return Double.parseDouble(n()); 
        } 
  
        String nline() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    }

   
     public static long[] randomize(long arr[])
    {
        Random rand = new Random();
for (int i = 0; i < arr.length; ++i) {
   int index = rand.nextInt(arr.length - i);
   long tmp = arr[arr.length - 1 - i];
   arr[arr.length - 1 - i] = arr[index];
   arr[index] = tmp;
}

return arr;
    } 

    static long mod = 1000000007;

  
    public static void main (String[] args) throws java.lang.Exception
    {
        FastReader sc = new FastReader();
        StringBuilder fo = new StringBuilder();

        int test=sc.ni();
        
        while(test-->0)
        {

            int n = sc.ni();

            char a[] = sc.n().toCharArray();


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

    public static long solve(int l, int u, char curr, char a[])
    {   
        //System.out.println(l+" "+u);
        if(l==u)
           {
                if(a[l]==curr)
                    return 0;
                else
                    return 1;
           }
        long count1=0, count2=0;

        for(int i=l;i<=((l+u)/2);i++)
        {
            if(a[i]!=curr)
                count1++;
        }

        for(int i=((l+u)/2)+1;i<=u;i++)
        {
            if(a[i]!=curr)
                count2++;
        }

        long pa1 = count1 + solve(((l+u)/2)+1, u, (char)((int)curr+1), a);

        long pa2 = count2 + solve(l, ((l+u)/2), (char)((int)curr+1), a);

        long ans = pa1<pa2?pa1:pa2;

        return ans;
    }
    
    
    
    
}
