from sys import stdin, setrecursionlimit
setrecursionlimit(10**8)
input = stdin.readline

T = int(input())
ans = 0

def isGood(msg, start, end, ch):
    global ans
    if (end - start) == 1:
        if msg[start] != ch:
            ans += 1
        return

    half = start + (end - start)//2
    cnt1 = 0
    cnt2 = 0
    for m in msg[start:half]:
        if m != ch:
            cnt1 += 1
    for m in msg[half:end]:
        if m != ch:
            cnt2 += 1
    if cnt1 > cnt2:
        ans += cnt2
        isGood(msg, start, half, chr(ord(ch)+1))
    else:
        ans += cnt1
        isGood(msg, half, end, chr(ord(ch) + 1))

for _ in range(T):
    size = int(input())
    msg = list(input().rstrip())
    isGood(msg, 0, size, 'a')
    print(ans)
    ans = 0