def abc(s,i,j,k):
    n = j-i+1
    if n==1:
        if s[i]==chr(k):
            return 0
        return 1
    x=0
    y=0
    for m in range(i,i+n//2):
        if s[m]!=chr(k):
            x+=1
    for m in range(i+n//2,j+1):
        if s[m]!=chr(k):
            y+=1
    return min(x+abc(s,i+n//2,j,k+1),y+abc(s,i,i+n//2-1,k+1))
t=int(input())
for _ in range(t):
    n=int(input())
    s=input()
    print(abc(s,0,n-1,97))
