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

public class Main
{
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
    public static void main(String[] args)
    {
        FastReader sc=new FastReader();
        int t = sc.nextInt();
        while (t-- > 0) {
            int n = sc.nextInt();
            String s = sc.nextLine();
            System.out.println(recursion(s,'a'));
        }
    }
    static int recursion(String s, char c){
        if(s.length()==1){
            if(s.charAt(0)==c)
                return 0;
            else
                return 1;
        }
        int mid = s.length()/2;
        int cntL = s.length()/2 - count(s.substring(mid),c) + recursion(s.substring(0,mid), (char) (c+1));
        int cntR = s.length()/2 - count(s.substring(0,mid),c) + recursion(s.substring(mid), (char) (c+1));
        return Math.min(cntL,cntR);
    }
    static int count(String s, char c){
        int count1=0;
        for(int i=0;i<s.length();i++){
            if(s.charAt(i)==c)
                count1++;
        }
        return count1;
    }
}
