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

public class Main {

    private static FastReader fr = new FastReader();
    private static Helper hp = new Helper();
    private static StringBuilder result = new StringBuilder();

    public static void main(String[] args) {
        Task solver = new Task();
        solver.solve();
    }

    static class Task {

        private int helper(String s, char ch){
            if(s.length() == 0) return 0;
            if(s.length() == 1){
                if(s.charAt(0) == ch) return 0;
                return 1;
            }
            int countLeft =0, countRight = 0;
            for(int i=0; i<s.length()/2; i++) if(s.charAt(i) == ch) countLeft++;
            for(int i=s.length()/2; i<s.length(); i++) if(s.charAt(i) == ch) countRight++;
            int moves = 0;
            if(countLeft == 0 & countRight == 0){
                int nextLeft = 0, nextRight = 0;
                char nextChar = (char) (ch + 1);
                for(int i=0; i<s.length()/2; i++) if(s.charAt(i) == nextChar) nextLeft++;
                for(int i=s.length()/2; i<s.length(); i++) if(s.charAt(i) == nextChar) nextRight++;
                moves += s.length()/2;
                if(nextLeft == nextRight){
                    moves += helper(s.substring(s.length()/2), nextChar);
                }
                else if(nextLeft > nextRight){
                    moves += helper(s.substring(0, s.length()/2), nextChar);
                }
                else{
                    moves += helper(s.substring(s.length()/2), nextChar);
                }
            }
            else if(countLeft >= countRight){
                moves += (s.length()/2 - countLeft);
                moves += helper(s.substring(s.length()/2), (char)(ch + 1));
            }
            else{
                moves += (s.length()/2 - countRight);
                moves += helper(s.substring(0, s.length()/2), (char)(ch+1));
            }
            return moves;
        }

        public void solve() {
            int nt = fr.ni();
            while(nt-- > 0){
                int n = fr.ni();
                String s = fr.next();
                int ans = helper(s, 'a');
                result.append(ans).append("\n");
            }
            System.out.println(result);
        }
    }

    static class Helper {
        public int[] ipArrInt(int n) {
            int[] arr = new int[n];
            for (int i = 0; i < n; i++)
                arr[i] = fr.ni();
            return arr;
        }

        public long[] ipArrLong(int n, int si) {
            long[] arr = new long[n];
            for (int i = si; i < n; i++)
                arr[i] = fr.nl();
            return arr;
        }
    }

    static class FastReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
        private static PrintWriter pw;

        public FastReader() {
            reader = new BufferedReader(new InputStreamReader(System.in));
            pw = new PrintWriter(System.out);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int ni() {
            return Integer.parseInt(next());
        }

        public long nl() {
            return Long.parseLong(next());
        }

        public double nd() {
            return Double.parseDouble(next());
        }

        public String rl() {
            try {
                return reader.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return null;
        }

        public void print(String str) {
            pw.print(str);
            pw.flush();
        }
    }
}