def answer(a,n,k):
	if n==1:
		if a==chr(k):
			return 0
		else:
			return 1
	l=0
	r=0
	for i in range(n//2):
		if a[i]!=chr(k):
			l+=1
	for i in range(n//2,n):
		if a[i]!=chr(k):
			r+=1
	return min( l+answer(a[n//2:],n//2,k+1) , r+answer(a[:n//2],n//2,k+1) )
	

	





t=int(input())
for i in range(t):
	n=int(input())
	a=input()
	x=answer(a,n,97)
	print(x)