import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)

def solve(s,c):
	n = len(s)
	if n==1:
		if ord(s[0])==c:
			return 0
		else:
			return 1

	count1, count2 = 0, 0
	for i in range(n//2):
		if ord(s[i])!=c:
			count1+=1
	for i in range(n//2,n):
		if ord(s[i])!=c:
			count2+=2
	# print (s,c,count1,count2)
	return min(count2+solve(s[0:n//2],c+1),count1+solve(s[n//2:],c+1))

for nt in range(int(input())):
	n = int(input())
	s = list(input())
	print (solve(s,97))