q='abcdefghijklmnopqrstuvwxyz'
def fun(beg,end,index):
    if beg==end:
        if s[beg]!=q[index]:
            return 1
        else:
            return 0
    else:
        mid=(beg+end)//2
        k=min(mid-beg+1-(s[beg:mid+1].count(q[index]))+fun(mid+1,end,index+1),fun(beg,mid,index+1)+end-mid-s    [mid+1:end+1].count(q[index]))
        return k

for _ in range(int(input())):
    n=int(input())
    s=input()
    s='0'+s
    print(fun(1,n,0))