def count_move(s,target):
	count = 0
	for i in s:
		if(i != target):
			count = count + 1
	return count

def find_target_string(s,target):
	if(len(s) == 1):
		if(s == target):
			return 0
		else:
			return 1
	n = int(len(s) / 2)
	l_min = find_target_string(s[0:n],chr(ord(target)+1)) + count_move(s[n:len(s)],target)
	r_min = find_target_string(s[n:len(s)],chr(ord(target)+1)) + count_move(s[0:n],target)
	return min(l_min,r_min)

n = int(input())
for i in range(0,n):
	input()
	s = input()
	print(find_target_string(s,'a'))