def calc(string, i):
	if len(string)==1:return string[0]!=i
	s1=0
	for t in range(len(string)//2):s1+=(string[t]!=i)
	s1+=calc(string[len(string)//2:],i+1)
	s2=0
	for t in range(len(string)//2,len(string)):s2+=(string[t]!=i)
	s2+=calc(string[:len(string)//2],i+1)
	return min(s1,s2)
for _ in range(int(input())):
	n=int(input())
	s=input()
	s=['abcdefghijklmnopqrstuvwxyz'.index(t) for t in s]
	print(int(calc(s,0)))