import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Stack;

public class A {

	static int mod = (int) 1e9 + 7;

	static int ar[];
	static Scanner sc = new Scanner(System.in);
	static StringBuilder out = new StringBuilder();
	static ArrayList<Integer> gr[]=new ArrayList[100000];
	
	static int pri[]=new int [(int)1e5+5];
	static void sieve() {
		pri[1]=1;
		for(int i=2;i<pri.length;i++) {
			pri[i]=i;
		}
		for(int i=2;i<Math.sqrt(pri.length);i++) {
			if(pri[i]!=i)continue;
			
				for(int j=i*i;j<pri.length;j+=i) {
					if(pri[j]==j)pri[j]=i;
				}
			
		}
	}

	public static void main(String[] args) throws IOException {
		int t = sc.nextInt();
		
		sieve();

		while (t-- > 0) {
			
			int n = sc.nextInt();
			String s = sc.next();
			out.append(solve(s, 0, n - 1, 'a'));
			out.append("\n");
		}
		System.out.print(out);
	}

	public static int solve(String s, int id, int n, char c) {
		if (id >= n) {
			return s.charAt(id) == c ? 0 : 1;
		}
		int fst = 0, second = 0;
		int mi = (id + n) / 2;
		for (int i = id; i <= mi; i++)
			if (s.charAt(i) != c)
				fst++;
		for (int i = mi + 1; i <= n; i++)
			if (s.charAt(i) != c)
				second++;
		return Math.min(fst + solve(s, mi + 1, n, (char) (c + 1)), second + solve(s, id, mi, (char) (c + 1)));
	}
}