def good(l,c):
	ch=chr(c)
	if len(l)==1:
		return(1 if ch!=l[0] else 0)
	k=len(l)//2
	lm=k-l[:k].count(ch)+good(l[k:],c+1)
	rm=k-l[k:].count(ch)+good(l[:k],c+1)
	return(min(lm,rm))
for ty in range(int(input())):
	n=int(input())
	a=input()
	print(good(a,ord('a')))
