import sys
input = lambda :sys.stdin.readline().rstrip()
v = lambda x:ord(x)-ord('a')
def f(l,r,ch):
    ct=0
    for i in range(l,r+1):
        if a[i]==ch:
            ct+=1
    return ct
def h(i,j,ch):
    ans = 0
    v1 = f(i,i,ch)+f(j,j,ch)
    v2 = f(i,i,ch+1)+f(j,j,ch+1)
    if v1==0:
        ans+=1
    if v2==0:
        ans+=1
    return ans
for _ in range(int(input())):
    n = int(input())
    a = list(map(lambda x:v(x),input()))
    if n==1:
        print(0 if a==[0] else 1)
        continue

    def g(i,j,l,ch):
        if l==0:
            return 0
        if l==1:
            return h(i,j,ch)
        op1 = f(i,i+l-1,ch)
        op2 = f(j-l+1,j,ch)
        return min(l-op1+g(i+l,j,l>>1,ch+1),l-op2+g(i,j-l,l>>1,ch+1))

    print(g(0,n-1,n>>1,0))
# acznmdlj