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

import static java.lang.Math.*;

public class Solution implements Runnable {
    
    
      
    
    public void solve() throws Exception {
    	int t=sc.nextInt();
    	while(t-->0)
    	{
    		int n=sc.nextInt();
    		
    		String s=sc.nextToken();
    		char x='a';
    		int minimum=0;
    		int result=helper(s,n,'a');
    		System.out.println(result);
    		
    		
    	}
    	
    	
    	
    	
    }
    public int helper(String s,int n,char x) throws Exception
	{
		if(s.length()==1)
		{
			if(s.charAt(0)==x)
				return 0;
			else return 1;
		}
		int count1=0;
		int count2=0;
		for(int i=0;i<n/2;i++)
		{
			if(s.charAt(i)!=x)
				count1++;
				
		}
		for(int i=n/2;i<n;i++)
		{
			if(s.charAt(i)!=x)
				count2++;
				
		}
		return Math.min(count1+helper(s.substring(n/2,n),n/2,(char)(x+1)), count2+helper(s.substring(0,n/2),n/2,(char)(x+1)));
		
	}
    
    static Throwable uncaught;

    BufferedReader in;
    FastScanner sc;
    PrintWriter out;

    @Override
    public void run() {
        try {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
            sc = new FastScanner(in);
            solve();
        } catch (Throwable uncaught) {
            Solution.uncaught = uncaught;
        } finally {
            out.close();
        }
    }

    public static void main(String[] args) throws Throwable {
        Thread thread = new Thread(null, new Solution(), "", (1 << 26));
        thread.start();
        thread.join();
        if (Solution.uncaught != null) {
            throw Solution.uncaught;
        }
    }

}

class FastScanner {

    BufferedReader in;
    StringTokenizer st;

    public FastScanner(BufferedReader in) {
        this.in = in;
    }

    public String nextToken() throws Exception {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }

    public int nextInt() throws Exception {
        return Integer.parseInt(nextToken());
    }

    public long nextLong() throws Exception {
        return Long.parseLong(nextToken());
    }

    public double nextDouble() throws Exception {
        return Double.parseDouble(nextToken());
    }

}