from math import log2
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))
    elif cnt1 < cnt2:
        ans += cnt1
        isGood(msg, half, end, chr(ord(ch) + 1))
    else:
        flag = True
        if cnt1 > cnt2:
            flag = True
        else:
            flag = False
        for i in range(1, int(log2(end - start)) + 1):
            nch = chr(ord(ch) + i)
            ncnt1 = 0
            ncnt2 = 0
            for m in msg[start:half]:
                if m != nch:
                    ncnt1 += 1
            for m in msg[half:start]:
                if m != nch:
                    ncnt2 += 1
            if ncnt1 > ncnt2:
                flag = True
                break
            elif ncnt1 < ncnt2:
                flag = False
                break
        if flag:
            ans += cnt1
            isGood(msg, half, end, chr(ord(ch) + 1))
        else:
            ans += cnt2
            isGood(msg, start, half, chr(ord(ch)+1))


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