q = int(input())

def util(s, l, id, st):
    if (l == 1):
        if ( st[s] == chr(id+ord('a')) ):
            return 0
        else:
            return 1
    
    lh = rh = 0
    
    for i in range(l):
        if (st[s+i] != chr(id+ord('a'))):
            if (i < l//2):
                lh+=1
            else:
                rh+=1
                
    return min(lh+util(s+int(l//2), int(l//2), id+1, st), rh+util(s, int(l//2), id+1, st)) 

for i in range(q):
    n = int(input())
    
    st = input().strip()
    
    print(util(0, len(st), 0, st))
    
    