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

public class AGoodString {
    public static void main(String[] args) {
        FastReader input=new FastReader();
        int t=input.nextInt();
        while(t-->0)
        {
            int n=input.nextInt();
            String s=input.next();
            System.out.println(minMoves(s,0,s.length()-1,'a'));
        }
    }
    public static int minMoves(String s,int i,int j,char ch)
    {
        if(i==j)
        {
            if(s.charAt(i)==ch)
            {
                return 0;
            }
            else
            {
                return 1;
            }
        }
        else
        {
            int m=(i+j)/2;
            int c1=0,c2=0;
            for(int k=i;k<=m;k++)
            {
                if(s.charAt(k)!=ch)
                {
                    c1++;
                }
            }
            for(int k=m+1;k<=j;k++)
            {
                if(s.charAt(k)!=ch)
                {
                    c2++;
                }
            }
            return Math.min(c1+minMoves(s,m+1,j,(char)(ch+1)),c2+minMoves(s,i,m,(char)(ch+1)));
        }
    }
    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;
        }
    }
}
