t=int(input())

az='abcdefghijklmnopqrstuvwxyz'

def aze(i,j,nb):
	if i==j:
		if s[i]==az[nb]:
			return(0)
		return(1)
	d=(j-i)//2
	diff=0
	for k in range(i,i+d+1):
		if s[k]!=az[nb]:
			diff+=1
	dif=0
	for k in range(i+d+1,j+1):
		if s[k]!=az[nb]:
			dif+=1
	return(min(aze(i,i+d,nb+1)+dif,aze(i+d+1,j,nb+1)+diff))


for _ in range(t):
	n=int(input())
	s=str(input())
	print(aze(0,n-1,0))


