for _ in range(int(input())):
    n=int(input())
    s=input()
    def getcost(l,r,c):
        cnt=0
        for i in range(l,r+1):
            if s[i]!=c:
                cnt+=1
        
        return cnt

    def getmin(l,r,c):
        if r==l:
            if s[l]==c:
                return 0
            else:
                return 1
        mid=(l+r)//2
        
        
        return min(getcost(l,mid,c)+getmin(mid+1,r,chr(ord(c)+1)),getcost(mid+1,r,c)+getmin(l,mid,chr(ord(c)+1)))
    ans=getmin(0,n-1,'a')
    print(ans)


        