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

public class aGoodString {

	static int solve(char ch[], int size, int x, char c){
		if(size==1) return (ch[0]==c)?x:x+1;
		int changesReq1=0, changesReq2=0;
		for(int i=0;i<size/2;i++){
			if(ch[i]!=c) changesReq1++;
			if(ch[i+(size/2)]!=c) changesReq2++;
		}
		char nch[] = new char[size/2];
		boolean forceChoice1=false;
		if(changesReq1==changesReq2){
			char next = c; next++;
			int nchangesReq1=0, nchangesReq2=0;
			for(int i=0;i<size/2;i++){
				if(ch[i]!=next) nchangesReq1++;
				if(ch[i+(size/2)]!=next) nchangesReq2++;
			}
			if(nchangesReq1>nchangesReq2) forceChoice1 = false;
			else forceChoice1 = true;
		}
		if(changesReq1>changesReq2||forceChoice1){
			for(int i=0;i<size/2;i++) nch[i] = ch[i];
			c++;
			return solve(nch,size/2,x+changesReq2,c);
		}
		else{
			for(int i=0;i<size/2;i++) nch[i] = ch[i+size/2];
			c++;
			return solve(nch,size/2,x+changesReq1,c);
		}
	}

	public static void main(String[] args) {
        FastScanner in = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int t = in.nextInt();
		while(t-->0){
			int n = in.nextInt();
			char ch[] = in.next().toCharArray();
			if(n!=1) out.println(solve(ch,n,0,'a'));
			else out.println((ch[0]=='a')?0:1);
		}
        out.flush();
	}
	
	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		
		String next() {
			while(!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				}catch(IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		String nextLine(){
			String s = "";
			try{
				s = br.readLine();
			}catch(IOException e){}
			return s;
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}

		int[] readArray(int n) {
			int a[] = new int[n];
			for(int i=0;i<n;i++) a[i] = nextInt();
			return a;
		}
		
	}
}