

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.*;





public class Main {
	public static int replace(String s,char c) {
		int ans=0;
		for(char c1:s.toCharArray())
			if(c1!=c) ans++;
		
		return ans;
	}
	
	public static int solve(String s,char c) {
		if(s.length()==1) 
			return s.charAt(0)==c? 0:1;
		if(s.length()==2) {
			int diff= Math.abs(s.charAt(0)-s.charAt(1));
			//System.out.println(s+" "+diff);
			if (diff==1&&((s.charAt(0)==c&&s.charAt(1)==c+1)||(s.charAt(0)==c+1&&s.charAt(1)==c))) return 0;
			
			if(s.charAt(0)==c||s.charAt(1)==c||s.charAt(0)==c+1||s.charAt(1)==c+1) return 1;
			
			else return 2;
			
			
		}
		int n=s.length();
		
		int ans1= solve(s.substring(0,n/2), (char) (c+1))+ replace(s.substring(n/2), c);
		int ans2= replace(s.substring(0,n/2), c)+ solve(s.substring(n/2), (char) (c+1));
		
		return Math.min(ans1, ans2);
		
	}
		
	
	public static void main(String[] args) {
		FastScanner scanner=new FastScanner();
	
		int t=scanner.nextInt();
		while(t-->0) {
			int n=scanner.nextInt();
			String string=scanner.next();
			int res= solve(string, 'a');
			System.out.println(res);
			
			
		}
		
					
		}

	
	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();
		}
		
		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;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
}

}
