def getcost(l,r,s,ch):
    count=0
    for i in range(l,r+1):
        if s[i]!=ch:
            count+=1
    return count

def helper(l,r,s,num):
    mid=l+(r-l)//2
    if l==r:
        if s[l]==chr(num):
            return 0
        else:
            return 1
    return min(getcost(l,mid,s,chr(num))+helper(mid+1,r,s,num+1),getcost(mid+1,r,s,chr(num))+helper(l,mid,s,num+1))
                    
def answer(n,s):
    if n==1:
        if s[0]=="a":
            return 0
        else:
            return 1
    l=0
    r=n-1
    mid=(l+r)//2
    return min(getcost(l,mid,s,"a")+helper(mid+1,r,s,ord("b")),getcost(mid+1,r,s,"a")+helper(l,mid,s,ord("b")))
    
    
    

    
t=int(input())
for i in range(t):
    n=int(input())
    s=input()
    print(answer(n,s))