import math
def make_good(word, ch):
	# number of minimum moves to make word a c good string
	# print(word)
	n = len(word)
	if (n == 1):
		if (word[0] == ch):
			return 0
		else:
			return 1
	# case1 - first half
	moves1 = 0
	for i in range(0,int(n/2)):
		if (word[i] != ch):
			moves1 += 1
	moves1 += make_good(word[int(n/2):], chr(ord(ch) + 1))

	# case2 - second half
	moves2 = 0
	for i in range(int(n/2),n):
		if (word[i] != ch):
			moves2 += 1
	moves2 += make_good(word[:int(n/2)], chr(ord(ch) + 1))
	# print(word,min(moves1,moves2))
	return min(moves1, moves2)

num_cases = int(input())
for _ in range(num_cases):
	n = int(input())
	input_word = input().strip()
	print(make_good(input_word,'a'))

# bbdcaaaa