def func(s,st,n,c):
	if (n==0):
		if (s[st] == c):
			return 0
		else:
			return 1
	a = 0
	b = 0
	for i in range(n):
		if (s[i+st] == c):
			a+=1
		if (s[i+st+n] == c):
			b+=1
	c2 = chr(ord(c)+1)
	a = (n-a) + func(s,st+n,n//2,c2)
	b = (n-b) + func(s,st,n//2,c2)
	return min(a,b)

for _ in range(int(input())):
	n = int(input())
	s = input()
	print(func(s,0,n//2,'a'))