import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public final class CodeForces {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int t = Integer.parseInt(br.readLine());
        while(t-->0) {
            int n = Integer.parseInt(br.readLine());
            String s = br.readLine();
            if(n > 1) {
                System.out.println(solve(s.substring(0, n / 2), s.substring(n / 2), 'a'));
            } else {
                System.out.println(s.charAt(0) == 'a' ? 0 : 1);
            }
        }
        br.close();
    }

    private static int solve(String s1, String s2, char c) {
        int count1 = 0, count2 = 0;
        if(s1.length() == 1) {
            char[] match = new char[2];
            match[0] = c;
            match[1] = (char) (c + 1);
            Arrays.sort(match);
            char[] a = new char[2];
            a[0] = s1.charAt(0);
            a[1] = s2.charAt(0);
            Arrays.sort(a);
            if(a[0] == match[0] && a[1] == match[1])
                return 0;
            else if(a[0] == match[0])
                return 1;
            else if(a[1] == match[1])
                return 1;
            else
                return 2;
        }
        for(int i=0; i<s1.length(); i++) {
            if(s1.charAt(i) != c)
                count1++;
            if(s2.charAt(i) != c)
                count2++;
        }
        char next = (char) (c + 1);
        return Math.min(count1 + solve(s2.substring(0, s2.length()/2), s2.substring(s2.length()/2), next), count2 + solve(s1.substring(0, s1.length()/2), s1.substring(s1.length()/2), next));
    }
}