t=int(input())
char="abcdefghijklmnopqrstuvwxyz"
bj=[[0]*131072]*26
ans=[[0]*131072]*26
def work(l,r,b):
	if(l==r-1):
		if(a[l]==char[b]):return 0
		else:return 1
	if(bj[b][l]): return ans[b][l]
	ans1=0
	mid=int((l+r)/2)
	for i in range(l,mid):
		if(a[i]!=char[b]):
			ans1+=1
	ans1+=work(mid,r,b+1)
	ans2=0
	for i in range(mid,r):
		if(a[i]!=char[b]):
			ans2+=1
	ans2+=work(l,mid,b+1)
	ans[b][l]=min(ans1,ans2)
	bj[b][l]=1
	return ans[b][l]
for i in range(1,t+1):
	n=int(input())
	a=input()
	for i in range(0,n):
		for j in range(0,26):
			bj[j][i]=0
	print(work(0,n,0))