import java.util.*;

public class a_good_string_codeforces656_q4 {

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner s = new Scanner(System.in);
		int tc = s.nextInt();

		for (int i = 0; i < tc; i++) {

			int n = s.nextInt();

			String str = s.next();
			// System.out.println(str);

			
			

			int ans = countchanges(str, 'a');
			System.out.println(ans);

		}
	}

	public static int countchanges(String str, char ch) {
		int l = str.length();
		if (str.length() == 1) {
			if (str.charAt(0) == ch) {
				return 0;
			} else {
				return 1;
			}
		}
		int count1 = 0;
		int count2 = 0;
		for (int i = 0; i < l / 2; i++) {
			if (str.charAt(i) != ch) {
				count1++;
			}
		}
		for (int i = l / 2; i < l; i++) {
			if (str.charAt(i) != ch) {
				count2++;
			}
		}

		return Math.min(count2 + countchanges(str.substring(0, l / 2), (char) (ch + 1)),
				count1 + countchanges(str.substring(l / 2, l), (char) (ch + 1)));

	}
}
