count=0
def c(li,l,h,good):
	global count
	if(h-l==1):
		if(li[l]==good):
			return 0
		return 1
	m=l+(h-l)//2
	if(li[l:m].count(good)>li[m:h].count(good)):
		return (h-l)//2-li[l:m].count(good) +c(li,m,h,chr(ord(good)+1))
	elif(li[l:m].count(good)<li[m:h].count(good)):
		return (h-l)//2-li[m:h].count(good) +c(li,l,m,chr(ord(good)+1))
	else:
		if(li[l:m].count(chr(ord(good)+1))>li[m:h].count(chr(ord(good)+1))):
			return (h-l)//2-li[m:h].count(good) +c(li,l,m,chr(ord(good)+1))
		else:
			return (h-l)//2-li[l:m].count(good) +c(li,m,h,chr(ord(good)+1))


def main():
	for _ in range(int(input())):
		n=int(input())
		a=list(input())
		print(c(a,0,n,'a'))
main()