def a_good(l,ch,n):
    if n==1:
        if l[0]==ch:
            return 0
        else:
            return 1
    else:
        temp1=l[0:n//2]
        temp2=l[n//2:]
        c1=temp1.count(ch)
        c2=temp2.count(ch)
        nextCh=chr(ord(ch)+1)
        if c1>=c2:
            ans=(n//2)-c1
            return ans+a_good(temp2,nextCh,n//2)
        else:
            ans=(n//2)-c2
            return ans+a_good(temp1,nextCh,n//2)

for _ in range(int(input())):
    n=int(input())
    s=input()
    print(a_good(s,'a',n))

