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

public class Question4 {

	static Scanner sc = new Scanner(System.in);
	static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
	
	public static void main(String[] args) throws IOException{
		
		int t = sc.nextInt();
		while(t-->0) {
			solve();
		}
		
	}
	
	public static void solve() throws IOException{
		
		int n = sc.nextInt();
		char[] arr = sc.next().toCharArray();
		
		int start = 0, end = n;
		char check = 'a';
		int ans = 0;
		
		while(start < end) {
			
			if(end - start == 1) {
				ans += checkFor(check, start, end, arr);
				break;
			}
			int mid = (start + end)/2;
			
			int aval = checkFor(check, start, mid, arr);
			int bval = checkFor(check, mid, end, arr);
			
			if(aval == -1 || bval == -1)break;
			
			if(aval <= bval) {
				ans += aval;
				start = mid;
			}
			else {
				
				ans += bval;
				ans += bval;
				end = mid;
			}
			check++;
			
			if(start >= end) {
				
				break;
			}
			
		}
		
		System.out.println(ans);
		
	}
	
	public static int checkFor(char c, int start, int end, char[] arr) {
		//System.out.println("from " + start + " to " + (end));
		if(start >= end)return -1;
		int count = 0;
		for(int i = start;i < end;i++) {
			if(arr[i] != c)count++;
		}
		
		return count;
	}
}
