from collections import defaultdict 
def solve(a,c,l,r):
    if l ==r:
        if a[l] == c:
            return 0 
        else:
            return 1 
    c1 = 0 
    c2 = 0 
    mid = (l+r)//2 
    for i in range(l,mid+1):
        if a[i] != c:
            c1 += 1 
    for i in range(mid+1,r+1):
        if a[i] != c:
            c2 +=1 
    x = solve(a,chr(ord(c)+ 1) , l, mid)
    y = solve(a,chr(ord(c)+1),mid+1,r)
    return min(c1+y,c2+x)

t = int(input())
while t:
    n = int(input())
    a= input()
    print(solve(a,'a',0,n-1))
    
    t-=1 