def g(s,i,j,c):
    ans=0
    for i in range(i,j+1):
        if s[i]!=c:
            ans+=1
    return ans

def f(s,c,i,j):
    if j==i:
        if s[i]==c:
            return 0
        else:
            return 1
    mid=(i+j)//2
    l=g(s,i,mid,c)
    r=g(s,mid+1,j,c)
    '''
    if l<r:
        return l+f(s,chr(1+ord(c)),mid+1,j)
    else:
        return r+f(s,chr(1+ord(c)),i,mid)
    '''
    return min(l+f(s,chr(1+ord(c)),mid+1,j),r+f(s,chr(1+ord(c)),i,mid))

t=int(input())
for _ in range(t):
    n=int(input())
    s=input()
    x=f(s,'a',0,n-1)
    print(x)