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

//System.out.println();
public class C
{
    public static int[] arr;
    public static int n;
    public static String s;
    public static int ans;
    public static void main(String[] args) throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int T = Integer.parseInt(br.readLine().trim());
        
        for(int t = 1; t <= T; t++)
        {
            n = Integer.parseInt(br.readLine().trim());
            s = br.readLine().trim();
            
            fn();
            //System.out.println(fn());
        }
    }
    
    public static void fn()
    {
        //System.out.println();
        //StringBuilder x = new StringBuilder(s);
        ans = 0;
    
        fn2(s, 'a');
        
        System.out.println(ans);
    }
    
    public static void fn2(String x, char c)
    {
        if(x.length() == 1){
            if(x.charAt(0) != c) ans++;
            return;
        }
        
        int len = x.length();
        String sub1 = x.substring(0, len/2);
        String sub2 = x.substring(len/2);
        
        if(check(sub1, c) >= check(sub2, c)){
            for(int i = 0; i < sub1.length(); i++)
                if(sub1.charAt(i) != c)
                    ans++;
                    
            fn2(sub2, c+=1);
        }
        
        else{
            for(int i = 0; i < sub2.length(); i++)
                if(sub2.charAt(i) != c)
                    ans++;
                    
            fn2(sub1, c+=1);
        }
    }
    
    public static int check(String x, char c)
    {
        int cnt = 0;
        for(int i = 0; i < x.length(); i++)
            if(x.charAt(i) == c) cnt++;
            
        return cnt;
    }
    
    public static int swap(int g1, int g2)
    {
        return g1;
    }
}