def cost(start,end,c):
    count=0
    for i in range(start,end+1):
        if s[i]!=c:
            count+=1 
    #print(start,end,count)
    return count
def divider(start,end,c="a"):
    mid=(start+end)//2   
    if start==end:
        if s[start]==c:
            return 0 
        else:
            return 1
    return min(cost(start,mid,c)+divider(mid+1,end,chr(ord(c)+1)),cost(mid+1,end,c)+divider(start,mid,chr(ord(c)+1))) 
t=int(input())
for _ in range(t):
    n=int(input())
    s=input()
    start=0
    end=n-1
    print(divider(start,end))  
#6
#8
#bbdcaaaa
#8
#asdfghjk
#8
#ceaaaabb
#8
#bbaaddcc
#1
#z
#2
#ac
#outputCopy
#0
#7
#4
#5
#1
#1