def ans(string,c,n):
	if(n==1):
		if(string[0]==c):
			return 0
		else:
			return 1
	count1=int(n/2)-string.count(c,0,int(n/2))
	count2=int(n/2)-string.count(c,int(n/2),n)
	sub1=ans(string[int(n/2):n],chr(ord(c)+1),int(n/2))
	sub2=ans(string[0:int(n/2)],chr(ord(c)+1),int(n/2))
	return min(count1+sub1,count2+sub2)

T=int(input())
for t in range(0,T):
	n=int(input())
	string=input()
	print(ans(string,'a',n))
