
def good_string(s,n,l,r):
    if l==r:
        if s[l]==chr(n):
            return 0
        else:
            return 1
    mid=(l+r)//2
    c1=0
    c2=0
    for i in range(l,mid+1):
        if s[i]!=chr(n):
            c1+=1
    for i in range(mid+1,r+1):
        if s[i]!=chr(n):
            c2+=1
    x=good_string(s,n+1,l,mid)
    y=good_string(s,n+1,mid+1,r)
    return min(c1+y,c2+x)

q=int(input())
for o in range(q):
    n=int(input())
    s=input()
    m=ord("a")
    ans=good_string(s,m,0,n-1)
    print(ans)