
def recursiveApproach(st,l,r,c):
	# print(c,st,l,r)
	if r-l==1:
		# print(c,st,r,l)
		if st[l]==c:
			# print(c)
			return 0
		else:
			return 1
	else:
		mid=(l+r)//2
		firstType=0
		for i in range(l,mid):
			if st[i]!=c:
				firstType+=1
		# print(i,"st",firstType)
		secondType=0
		for i in range(mid,r):
			if st[i]!=c:
				secondType+=1
		# print(i,"j",secondType)
		# print(firstType,secondType)
		return( min(secondType+recursiveApproach(st,l,mid,chr(ord(c)+1)),firstType+recursiveApproach(st,mid,r,chr(ord(c)+1))))
t=int(input())
for i in range(t):
	n=int(input())
	st=input()
	print(recursiveApproach(st,0,n,"a"),)
