import math
def calc(l,r,c,s):
    if(r==l):
        if(s[l]==c):
            return 0
        else:
            return 1
    m=(l+r)//2
    c1=((r-l+1)//2)-s[l:m+1].count(c)+calc(m+1,r,chr(ord(c)+1),s)
    c2=((r-l+1)//2)-s[m+1:r+1].count(c)+calc(l,m,chr(ord(c)+1),s)
    return min(c1,c2)
t=int(input())
for w in range(t):
    n=int(input())
    s=input()
    if(n==1):
        if(s=='a'):
            print(0)
        else:
            print(1)
    else:
        print(calc(0,n-1,'a',s))