from sys import stdin
input=lambda : stdin.readline().strip()
from math import ceil,sqrt,factorial,gcd,log
from collections import deque
from bisect import bisect_left,bisect_right
def aise(l,r,c):
	if l>r:
		return 0
	# print(l,r)
	if l==r:
		if s[l]==c:
			return 0
		else:
			return 1

	a={}
	b={}
	count=0
	m=(l+r)//2
	for i in range(l,m+1):
		if s[i] in a:
			a[s[i]]+=1
		else:
			a[s[i]]=1
	for i in range(m+1,r+1):
		if s[i] in b:
			b[s[i]]+=1
		else:
			b[s[i]]=1
	f=ceil((r-l+1)//2)
	if c in a:
		e=f-a[c]+aise(m+1,r,chr(ord(c)+1))
	else:
		e=f+aise(m+1,r,chr(ord(c)+1))
	if c in b:
		# print(b[c],l,r,m)
		w=f-b[c]+aise(l,m,chr(ord(c)+1))
	else:
		w=f+aise(l,m,chr(ord(c)+1))
	# print(e,w,l,r)
	return min(e,w)
for _ in range(int(input())):
	n=int(input())
	s=input()
	print(aise(0,n-1,'a'))