import math
import bisect
import copy
import time
from collections import Counter
#map(int,input().split())
#int(x) for x in input().split()
def f(cur,le,re,ln):
	if ln==0:
		if l[le]!=cur:
			return 1
		else:
			return 0 

	count1=0
	count2=0
	for i in range(le,le+ln):
		if l[i]!=cur:
			count1+=1
	for i in range(le+ln,re+1):
		if l[i]!=cur:
			count2+=1
	#print(cur,count1,count2)
	count1+=f(cur+1,le+ln,re,ln>>1)
	count2+=f(cur+1,le,le+ln-1,ln>>1)
	return min(count1,count2)




for _ in range(int(input())):
	n=int(input())
	x=input()
	l=[]
	for i in range(n):
		l.append(ord(x[i])-97+1)
	print(f(1,0,n-1,n>>1))









