//package codeforces;
import java.io.PrintWriter;
import java.util.*;
public class codeforces {
	public static void main(String[] args) {
		PrintWriter out=new PrintWriter(System.out);
    	Scanner s=new Scanner(System.in);  
    	//System.out.println((char)('a'+1));
    	int T=s.nextInt();
		for (int tt=0; tt<T; tt++) {
			int n=s.nextInt();
			char a[]=s.next().toCharArray();
			System.out.println(solve(a,0,n-1,'a'));
		}
    	out.close();
	    s.close();
	}
	
	static void sort(int[] a) {
		ArrayList<Integer> l=new ArrayList<>();
		for (int i:a) l.add(i);
		Collections.sort(l);
		for (int i=0; i<a.length; i++) a[i]=l.get(i);
	}
	static void sortcol(long a[][],int c) {
		Arrays.sort(a, (x, y) -> {
			if (x[c] != y[c]) return(int)( x[c] - y[c]);
			return (int)(y[0] - x[0]);
		});
	}
	public static int solve(char a[],int i,int j,char c) {
		if(i==j) {
			if(a[i]==c) {
				return 0;
			}else {
				return 1;
			}
		}
		int mid=(i+j)/2;
		int count1=0,count2=0;
		for(int k=i;k<=mid;k++) {
			if(a[k]==c) {
				count1++;
			}
		}
		for(int k=mid+1;k<=j;k++) {
			if(a[k]==c) {
				count2++;
			}
		}
		//System.out.println(count1+" "+count2 +" "+mid);
		if(count1>count2) {
			return (j-i+1)/2-count1+solve(a,mid+1,j,(char)(c+1));
		}else if(count1<count2){
			return (j-i+1)/2-count2+solve(a,i,mid,(char)(c+1));
		}else {
			return (j-i+1)/2-count1+Math.min(solve(a,mid+1,j,(char)(c+1)), solve(a,i,mid,(char)(c+1)));
		}
	}
}

