def solve(x, z):
	if len(x) == 0:
		return 0
	if len(x) == 1:
		return int(x!=z)

	m = len(x)//2
	l = x[:m]
	r = x[m:]
	a = (m-l.count(z)) + solve(r, chr(ord(z)+1))
	b = (m-r.count(z)) + solve(l, chr(ord(z)+1))
	return min(a, b)

def getCost(l, r, ch):
	count = 0
	for i in range(l, r+1):
		if arr[i]!=ch:
			count+=1
	return count

def getMin(l, r, ch):
	print("yes")
	if l==r:
		if arr[l]==ch:
			return 0
		else:
			return 1
	mid = (l+r)//2

	return min(getCost(l, mid, ch)+getMin(mid+1, r, chr(ord(ch)+1)), getCost(mid+1, r, ch)+getMin(l, mid, chr(ord(ch)+1)))

for _ in range(int(input())):
	n = int(input())
	s = str(input())	
	# arr = list(str(input()))
	print(solve(s, 'a'))
	# print(getMin(1, n, 'a'))


	# ans = 0
	# bns = 0
	# look = 'abcdefghijklmnopqr'
	# t = s[::-1]
	# if n == 1 and s[0] != 'a':
	# 	ans = 1
	# # elif n == 1 and s[0] == 'a':
	# 	# ans = 0
	# else:
	# 	counter = 2
	# 	temp = 0
	# 	while counter<n:
	# 		for i in range(counter):
	# 			if s[i] != look[temp]:
	# 				ans+=1
	# 			if t[i] != look[temp]:
	# 				bns+=1
	# 		counter *= 2
	# 		temp += 1

	# print(min(ans, bns))