def solve(query,good,length):
    if length == 1:
        if query == good:
            return 0
        else:
            return 1
    else:
        mid = int(length/2)
        left = query[0:mid]
        right = query[mid:length]
        leftCost = 0
        rightCost = 0
        for s in left:
            if s != good:
                leftCost += 1
        for s in right:
            if s != good:
                rightCost += 1
        good = ord(good)
        good += 1
        good = chr(good)
        leftSolve = leftCost + solve(right,good,int(length/2))
        rightSolve = rightCost + solve(left,good,int(length/2))
        
        return min(leftSolve,rightSolve)
            

TC = int(input())

while TC:
    n = int(input())
    S = input()
    print(solve(S,'a',n))
    
    
    TC -= 1
