def good_string(n,i,j,c,s):
    if i==j:
        if s[i]==c:
            return 0
        else:
            return 1
    mid=(j+i+1)//2
    count=0
    for k in range(i,mid):
        if s[k]!=c:
            count+=1
    ans1=count+good_string(n,mid,j,chr(ord(c)+1),s)
    #print(ans1)
    count=0
    for k in range(mid,j+1):
        if s[k]!=c:
            count+=1
    ans2=count+good_string(n,i,mid-1,chr(ord(c)+1),s)
    #print(ans2)
    return min(ans1,ans2)
t=int(input())
for i in range(t):
    n=int(input())
    s=input()
    print(good_string(n,0,n-1,"a",s))