import sys
input = sys.stdin.readline
def counter(char,l,r):
    mina1,mina2=0,0
    mid=(l+r)//2
    if l==r:
        if s[l]==char:
            return(0)
        else:
            return(1)
    for i in range(l,mid+1):
        if s[i]!=char:
            mina1+=1
    for i in range(mid+1,r+1):
        if s[i]!=char:
            mina2+=1
    return(min(mina1+counter(chr(ord(char)+1),mid+1,r),mina2+counter(chr(ord(char)+1),l,mid)))
t=int(input())
for i in range(t):
    n=int(input())
    s=input()
    print(counter('a',0,n-1))
            
