import java.util.*;
import java.io.*;
public class aGoodString {
    static String alphabet = "abcdefghijklmnopqrstuvwxyz";
    public static void main(String args[]) {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int t = Integer.parseInt(in.nextLine());
        for(int i = 0; i < t; i++)
        {
            int n = Integer.parseInt(in.nextLine());
            String s = in.nextLine();
            int letter = 0;
            out.println(getCount(0, n, letter, s));
        }
        out.close();
    }
    public static int getCount(int l, int r, int letter, String s)
    {
        int mid = (r - l) / 2;
        String character = alphabet.substring(letter, letter + 1);
        if(r - l == 1)
        {
            if(s.equals(character))
            {
                return 0;
            }
            else
            {
                return 1;
            }
        }
        int lcounter = s.length() / 2;
        int rcounter = s.length() / 2;
        for(int i = 0; i < mid; i++)
        {
            if(s.substring(i, i + 1).equals(character))
            {
                lcounter--;
            }
        }
        for(int i = mid; i < s.length(); i++)
        {
            if(s.substring(i, i + 1).equals(character))
            {
                rcounter--;
            }
        }
        int ans = 0;
        int left = rcounter + getCount(0, mid,letter + 1, s.substring(0, mid));
        int right = lcounter + getCount(mid, s.length(),letter + 1, s.substring(mid));
        if(left < right)
        {
            ans = left;
        }
        else
        {
            ans = right;
        }
        return ans;
    }
}
