def dfs(arr, c):
    if len(arr) == 1:
        if arr[0] == c:
            return 0
        return 1
    pr = 0
    po = 0

    mid = len(arr)//2
    for i in range(len(arr)):
        if arr[i] == c:
            if i < mid:
                pr += 1
            else:
                po += 1
    nex = chr(ord(c)+1)
    x1 = len(arr)//2 - po + dfs(arr[:mid], nex)
    x2 = len(arr)//2 - pr + dfs(arr[mid:], nex)
    return min(x1, x2)
T = int(input())
while T > 0:
    n = int(input())
    arr = input()
    res = dfs(arr, 'a')
    print(res)
    T -= 1
    