import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

public class AGoodString {

	public static void main(String[] args) throws NumberFormatException, IOException {

		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int t = Integer.parseInt(reader.readLine());
		while (t-- > 0) {
			reader.readLine();
			String nkz = reader.readLine();
			int result = solve(nkz);
			System.out.println(result);
		}
	}

	private static int solve(String inp) {
		return rec(inp, 0, inp.length() - 1, 'a');
	}

	private static int rec(String inp, int i, int j, int c) {

		if (i == j) {
			if((inp.charAt(i) -'a') != (c - 'a')) {
				return 1;
			} else {
				return 0;
			}
		}

		int l = j - i + 1;

		int v1 = rec(inp, i, i + (l / 2) - 1, c + 1) + toReplace(inp, i + (l / 2), j, c);
		int v2 = rec(inp, i + (l / 2), j, c + 1) + toReplace(inp, i, i + (l / 2) - 1, c);

		return Math.min(v1, v2);
	}

	private static int toReplace(String inp, int i, int j, int c) {
		int count = 0;
		for (int k = i; k <= j; k++) {
			if ((inp.charAt(k) -'a') != (c - 'a')) {
				count++;
			}
		}
		return count;
	}

}
