def rec(ar,al,k):
    if(k==1):
        if(ar[0]==al):
            return 0
        else:
            return 1
    k=k//2
    t=ar[:k].count(al)
    t=k-t
    m=ar[k:].count(al)
    m=k-m
    al=chr(ord(al)+1)
    return min(t+rec(ar[k:],al,k),m+rec(ar[:k],al,k))
for _ in range(int(input())):
    n=int(input())
    arr=list(input())
    ch="a"
    print(rec(arr,ch,n))