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

public final class CodeForces {
    static int count;
    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();
            count = 0;
            if(n > 1) {
                solve(s.substring(0, n / 2), s.substring(n / 2, n), 'a');
            } else {
                if(s.charAt(0) != 'a')
                    count++;
            }
            System.out.println(count);
        }
        br.close();
    }

    private static void solve(String s1, String s2, char c) {
        //System.out.println(s1 + " " + s2);
        int count1 = 0, count2 = 0;
        if(s1.length() == 0 && s2.length() == 0)
            return;
        if(s1.length() == 1) {
            char next = (char) (c + 1);
            char[] a = new char[2];
            a[0] = s1.charAt(0);
            a[1] = s2.charAt(0);
            Arrays.sort(a);
            char[] match = new char[2];
            match[0] = next;
            match[1] = c;
            Arrays.sort(match);
            if(a[0] == match[0] && a[1] == match[1])
                return;
            else if(a[0] == match[0]) {
                count++;
                return;
            } else if(a[1] == match[1]) {
                count++;
                return;
            } else {
                count += 2;
                return;
            }
        }
        char next = (char) (c + 1);
        int nextCount1 = 0, nextCount2 = 0;
        for(int i=0; i<s1.length(); i++) {
            if(s1.charAt(i) == c)
                count1++;
            if(s2.charAt(i) == c)
                count2++;
            if(s1.charAt(i) == next)
                nextCount1++;
            if(s2.charAt(i) == next)
                nextCount2++;
        }
        if(count1 > count2) {
            for(int j=0; j<s1.length(); j++) {
                if(s1.charAt(j) != c) {
                    count++;
                }
            }
            solve(s2.substring(0, s2.length()/2), s2.substring(s2.length()/2), (char) (c+1));
        } else if(count1 < count2){
            for(int j=0; j<s2.length(); j++) {
                if(s2.charAt(j) != c)
                    count++;
            }
            solve(s1.substring(0, s1.length()/2), s1.substring(s1.length()/2), (char) (c+1));
        } else {
            if(nextCount1 > nextCount2) {
                for(int j=0; j<s2.length(); j++) {
                    if(s2.charAt(j) != c)
                        count++;
                }
                solve(s1.substring(0, s1.length()/2), s1.substring(s1.length()/2), next);
            } else {
                for(int j=0; j<s1.length(); j++) {
                    if(s1.charAt(j) != c)
                        count++;
                }
                solve(s2.substring(0, s2.length()/2), s2.substring(s2.length()/2), (char) (c+1));
            }
        }
    }
}