t=int(input())
f=int
def makgood(st,ch,n):
	if n==1:
		if st==ch:
			return 0
		else:
			return 1
	k=f(n/2)
	a=st[:k].count(ch)
	b=st[k:].count(ch)
	nx=chr(ord(ch)+1)
	c=min((k-b+makgood(st[:k],nx,k)),k-a+makgood(st[k:],nx,k))
	
	
	return c
for _ in range(t):
	n=int(input())
	s=input()
	print(makgood(s,"a",n))