import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD
    {
        public void solve(int testNumber, Scanner in, PrintWriter out)
        {
            int T = in.nextInt();
            while (T-- > 0)
            {
                solve(in, out);
            }
        }

        private void solve(Scanner in, PrintWriter out)
        {
            int N = in.nextInt();
            String S = in.next();
            out.println(recurr(0, N - 1, 'a', S));
        }

        private int recurr(int start, int end, char a, String S)
        {
            if (start == end) return S.charAt(start) == a ? 0 : 1;

            int first = 0, second = 0;
            int mid = start + ((end - start) / 2);
            for (int i = start; i <= mid; i++)
            {
                if (S.charAt(i) == a) continue;
                first++;
            }
            for (int i = mid + 1; i <= end; i++)
            {
                if (S.charAt(i) == a) continue;
                second++;
            }
        /*if (first < second){
            return first + recurr(mid + 1, end, (char) (a + 1), S);
        }else if (first > second) {
            return second + recurr(start, mid, (char) (a + 1), S);
        } else {
            return Math.min(first + recurr(mid + 1, end, (char) (a + 1), S), second + recurr(start, mid, (char) (a + 1), S));
        }*/
            return Math.min(first + recurr(mid + 1, end, (char) (a + 1), S), second + recurr(start, mid, (char) (a + 1), S));
        }

    }
}

