def recur(s,char,start,end,curr):
	global ans
	if(end-start==0):
		if(s[start]!=char):
			curr+=1
		if(curr<ans):
			ans=curr
		return
	val1=0
	val2=0
	l=(end-start+1)//2
	for i in range(start,start+l):
		if(s[i]!=char):
			val1+=1
	for i in range(start+l,end+1):
		if(s[i]!=char):
			val2+=1
	char=chr(ord(char)+1)
	recur(s,char,start,start+l-1,curr+val2)
	recur(s,char,start+l,end,curr+val1)

t=int(input())
for _ in range(t):
	global ans
	ans=10000000
	n=int(input())
	s=input()
	recur(s,'a',0,n-1,0)
	print(ans)