def count(l,r,s,character):

	if (l+1==r):
		if(s[l]==character):
			return 0
		else:
			return 1
	mid=int((l+r)/2)
	l_count	= s[l:mid].count(character)
	r_count = s[mid:r].count(character)

	#print(chr(ord(character)+1))
	answer1 = int( (r-l)/2 ) - l_count
	answer1+=count(mid,r,s,chr(ord(character)+1))

	answer2 = int( (r-l)/2 ) - r_count
	answer2+=count(l,mid,s,chr(ord(character)+1))
	

	return min(answer1,answer2)


t= int(input())

for i in range(t):
	n=int(input())
	s=input()

	print(count(0,n,s,'a'))




