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

public class Problem_D {
	static final int INF = Integer.MAX_VALUE / 2;
	static char[] S;

	public static int solve1(int start, int len, int c) {
		int cnt = len;
		for (int i = 0; i < len; i++) {
			if (S[start + i] == c) {
				cnt--;
			}
		}
		return cnt;
	}

	public static int solve2(int start, int len, int c) {
		if (len == 1) {
			return S[start] == c ? 0 : 1;
		}
		int ret = Math.min(solve1(start, len / 2, c) + solve2(start + len / 2, len / 2, c + 1),
				solve1(start + len / 2, len / 2, c) + solve2(start, len / 2, c + 1));
		return ret;
	}

	public static void main(String[] args) {
		InputReader in = new InputReader();
		StringBuilder out = new StringBuilder();

		int T = in.nextInt();
		while (T-- > 0) {
			int N = in.nextInt();
			S = in.nextLine().toCharArray();
			out.append(solve2(0, N, 97)).append('\n');
		}

		System.out.print(out);
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer st;

		public InputReader() {
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				st = new StringTokenizer(nextLine());
			}
			return st.nextToken();
		}

		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return null;
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}
	}
}
