import string
t=int(input())

def find_num(s,i,suma):
	#print(s,suma)
	if len(s)==1:
		if s[0]==string.ascii_lowercase[i]:
			return 0
		else:
			return 1
	else:
		x=len(s)//2
		s1=s[:x]
		s2=s[x:]
		c1=x-s1.count(string.ascii_lowercase[i])
		c2=x-s2.count(string.ascii_lowercase[i])
		suma+=min(c1+find_num(s2,i+1,suma),c2+find_num(s1,i+1,suma))
	return suma
while t:
	t-=1
	input()
	s=input()
	print(find_num(s,0,0))
