import sys
import math
from collections import defaultdict,Counter

input=sys.stdin.readline
def print(x):
    sys.stdout.write(str(x)+"\n")

def find(s1,v):
    # global f
    l=len(s1)
    if l==1:
        if s1!=chr(v):
            return 1
        return 0

    c1=l//2-s1[:l//2].count(chr(v))
    c2=l//2-s1[l//2:].count(chr(v))
    return min(c1+find(s1[l//2:],v+1),c2+find(s1[:l//2],v+1))
    # if c1>c2:
    #     d[k]+=l//2-c1
    #     find(s1[l//2:],v+1,k)
    # elif c1<c2:
    #     d[k]+=l//2-c2
    #     find(s1[:l//2],v+1,k)
    # else:
    #     d[k]+=l//2-c1
    #     f+=1
    #     d[f]=d[k]
    #     find(s1[:l//2],v+1,f)
    #     find(s1[l//2:],v+1,k)


# sys.stdout=open("CP3/output.txt",'w')
# sys.stdin=open("CP3/input.txt",'r')

# m=pow(10,9)+7
t=int(input())
for i in range(t):
    n=int(input())
    s=input().strip()
    # d={1:0}
    # f=1
    ans=find(s,97)
    print(ans)