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

public class D {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		while(t-->0) {
			int n = sc.nextInt();
			String s = sc.next();
			int ans = calculate(s, 'a');
			System.out.println(ans);
		}
	}
	public static int calculate(String s, char c) {
		if(s.length() == 1) {
			return (s.charAt(0) != c ? 1 : 0); 
		}
		int mid = s.length()/2;
		int cl = calculate(s.substring(0, mid), (char) (c+1));
		cl += s.length()/2 - count(s.substring(mid, s.length()), c);
		int cr = calculate(s.substring(mid, s.length()), (char) (c+1));
		cr += s.length()/2 - count(s.substring(0, mid), c);
		return Math.min(cl, cr);
	}
	public static int count(String s, char c) {
		int res = 0;
		for(int i = 0; i < s.length(); i++) {
			if(s.charAt(i) == c) {
				res++;
			}
		}
		return res;
	}
}
