import java.util.*; 
import java.io.*;
public class Main {
    public 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; 
        } 
    } 
   
     
    

    static char c[];
    public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
    public static int hwg(int L, int R, char a) {
        if ((R-L) == 1) {
            if (c[L] == a) {
                return 0;
            } else {
                return 1;
            }
        }
    int i,a1=0,a2=0,b1=0,b2=0;
     int N=(R-L)/2;
    for (i=L; i<(L+N); i++) {
        if (c[i]!=a) {
            a1++;
        }
    }
    for (i=L+N; i<(R); i++) {
        if (c[i]!= a) {
            a2++;
        }
    }
 
    b1=hwg(L+N, R, (char)(a + 1));
    b2=hwg(L,L+N, (char)(a + 1));
    int mn=Math.min(a1+b1, a2+b2);
 
    return mn;
    }
    public static void main(String[] args) {
        FastReader sc = new FastReader();
        int tc = sc.nextInt();
        while (tc-->0) {
            int n = sc.nextInt();
            String s = sc.next();
            c = s.toCharArray();
            int ans = hwg(0,n,'a');
            out.println(ans);
        }
        out.close();
    }
}