import sys
sys.setrecursionlimit (int(1e6))

def solve (L, target, i, j): 

    targetChar = chr(ord('a') + target) 

    if i == j: 
        if L[i] == targetChar: return 0 
        else: return 1 
    
    n = j-i+1 
    mid = (i+j)//2 
    countFirst = 0 
    for k in range (i, mid+1): 
        if L[k] == targetChar: 
            countFirst += 1 
    ans1 = n//2 -countFirst + solve(L, target+1, mid+1, j)  

    countSecond = 0 
    for k in range (mid+1, j+1): 
        if L[k] == targetChar: 
            countSecond += 1 
    ans2 = n//2 -countSecond + solve(L, target+1, i, mid) 

    return min(ans1, ans2) 

t = int(input()) 
for _ in range (t): 
    _ = int(input()) 
    s = input() 
    print (solve (s, 0, 0, len(s)-1))  