def count(s,c):
    v = 0
    for i in s:
        v+=(i==c)
    return v

def calc(l,r,c):
    if r==l:
        return 0
    elif r-l==1:
        if s[l:r]==c:
            return 0
        else:
            return 1
    else:
        mid = (l+r)//2
        cntl = (r-l)//2-count(s[l:mid],c)+calc(mid,r,chr(ord(c)+1))
        cntr = (r-l)//2-count(s[mid:r],c)+calc(l,mid,chr(ord(c)+1))
        return min(cntl,cntr)

cases = int(input())
for t in range(cases):
    n = int(input())
    s = input()
    print(calc(0,n,'a'))