from sys import stdin,stdout
from math import gcd,sqrt
from collections import deque
input=stdin.readline
R=lambda:map(int,input().split())
I=lambda:int(input())
S=lambda:input().rstrip('\n')
L=lambda:list(R())
P=lambda x:stdout.write(x)
lcm=lambda x,y:(x*y)//gcd(x,y)
hg=lambda x,y:((y+x-1)//x)*x
pw=lambda x:0 if x==1 else 1+pw(x//2)
chk=lambda x:chk(x//2) if not x%2 else True if x==1 else False
sm=lambda x:(x**2+x)//2
N=10**9+7
c=''.join([chr(i+97) for i in range(26)])
def solve(s,n,p):
	if n==1:return 0 if s==c[p] else 1
	cnt1=cnt2=0
	for i in range(n//2):
		if s[i]!=c[p]:cnt1+=1
		if s[-i-1]!=c[p]:cnt2+=1
	return min(cnt1+solve(s[n//2:],n//2,p+1),cnt2+solve(s[:n//2],n//2,p+1))
for i in range(I()):
	n=I()
	a=S()
	print(solve(a,n,0))