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

public class D {
    public static int getFrequency(String word, char ch) {
        int cnt = 0;
        for (char temp :
                word.toCharArray()) {
            if (temp == ch)
                cnt++;
        }
        return cnt;
    }

    public static int makeaGood(String word, char ch) {
        if (word.length() == 1)
            return word.charAt(0) == ch ? 0 : 1;
        int mid = word.length() / 2;
        int forLeft = makeaGood(word.substring(0, mid), (char) (ch + 1));
        forLeft += mid - getFrequency(word.substring(mid), ch);
        int forRight = makeaGood(word.substring(mid), (char) (ch + 1));
        forRight += mid - getFrequency(word.substring(0, mid), ch);
        return Math.min(forLeft, forRight);
    }

    public static void main(String[] args) throws Exception {
        BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        int t = Integer.parseInt(buffer.readLine());
        while (t-- > 0) {
            int n = Integer.parseInt(buffer.readLine());
            String s = buffer.readLine();
            sb.append(makeaGood(s, 'a') + "\n");
        }
        System.out.println(sb);
    }
}
