def go(arr,c):
    if len(arr)==1:
        if arr[0]==c:
            return 0
        else:
            return 1
    l,r=0,0
    n=len(arr)
    for i in range(0,n//2):
        if arr[i]==c:
            l+=1
    for i in range(n // 2,n):
        if arr[i] == c:
            r += 1
    d=chr(ord(c)+1)
    b,a=r+(n//2-l),l+(n//2-r)

    return min(a+max(0,go(arr[:n//2],d)-l),b+max(0,go(arr[n//2:],d)-r))




n = int(input())

for i in range(n):
    n=int(input())
    arr=input()
    ans=go(arr,'a')
    print(ans)
