t=int(input())
def count(s,c):
    co=0
    for i in s:
        if i!=c:
             co+=1

    return co

def calc(s,l,r,c):
    if l==r:
        if s[l]==c:
            return 0
        else:
            return 1

    mid=(r+l)//2

    cntl=count(s[l:mid+1],c)+calc(s,mid+1,r,chr(ord(c) + 1) )
    cntr=count(s[mid+1:r+1],c)+calc(s,l,mid,chr(ord(c) + 1) )
    # print(s,l,r,cntl,cntr)
    return min(cntl,cntr)



for _ in range(t):
    n=int(input())
    s=input()
    print(calc(s,0,n-1,'a'))