t = int(input())
for ex in range(t):
    n = int(input())
    s = str(input())
    code = ord('a')
    k = 0
    while n > 1:
        n = n // 2
        k += 1
    ans = 0
    start = 0
    end = n

    while code < ord('a') + k:
        left = 0
        right = 0
        for i in range(0, len(s) // 2):
            if ord(s[i]) != code:
                left += 1
        for i in range(len(s) // 2, len(s)):
            if ord(s[i]) != code:
                right += 1
        if left <= right:
            ans += left
            s = s[len(s) // 2: len(s)]
        else:
            ans += right
            s = s[0: len(s) // 2]
        code += 1
    if len(s) == 1:
        if ord(s[0]) != code:
            ans += 1
    print(ans)