'''Author- Akshit Monga'''

s=''
f=0
def bracktrack(a,b,val,ans):
    global s
    global f
    if a==b:
        if s[a]==chr(val):
            f=min(f,ans)
        else:
            f=min(f,ans+1)
        return
    m=(a+b)//2
    temp=ans
    for i in range(a,m+1):
        if s[i]!=chr(val):
            temp+=1
    bracktrack(m+1,b,val+1,temp)
    temp = ans
    for i in range(m+1,b+1):
        if s[i]!=chr(val):
            temp+=1
    bracktrack(a,m,val+1,temp)

import sys
# input=sys.stdin.readline
t = int(input())
for _ in range(t):
    n=int(input())
    s=input()
    f=n
    bracktrack(0,n-1,97,0)
    print(f)
