def cost(s,l,r,ch):
    count=0
    for i in range(l,r):
        if s[i]!=ch:
            count+=1
    return count


def solve(s,l,r,ch):
    if l+1==r:
        if s[l]==ch:
            return 0
        return 1
    mid=(l+r)//2
    return min((cost(s,l,mid,ch)+solve(s,mid,r,chr(ord(ch)+1))) , (cost(s,mid,r,ch)+solve(s,l,mid,chr(ord(ch)+1))))


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



