/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
    static int[][]arr;
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		/*BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		int T=Integer.parseInt(br.readLine());*/
// 		StringTokenizer st=new StringTokenizer(br.readLine());
		Scanner sc=new Scanner(System.in);
		int T=sc.nextInt();
		for (int t=1;t<=T;t++){
		    int n=sc.nextInt();
		    String s=sc.next();
		    arr=new int[26][n];
		    for(int i=0;i<n;i++){
		        arr[s.charAt(i)-'a'][i]++;
		    }
		    for(int j=0;j<26;j++){
		    for(int i=1;i<n;i++){
		        arr[j][i]+=arr[j][i-1];
		    }
		    }
		    System.out.println(fun('a',0,n-1));
		}
	}
	static int fun(char c,int start,int end){
	    if(start==end){
	        return end-start+1-(arr[c-'a'][end]-(start==0?0:arr[c-'a'][start-1]));
	    }
	    int n=end-start+1;
	    int fun1=n/2-(arr[c-'a'][start+n/2-1]-(start==0?0:arr[c-'a'][start-1]))+fun((char)(c+1),start+n/2,end);
	    int fun2=n/2-(arr[c-'a'][end]-arr[c-'a'][start+n/2-1])+fun((char)(c+1),start,start+n/2-1);
	    return Math.min(fun1,fun2);
	}
}
