from math import log2


def dfs(a, b, num, kek, symb):
    global ans
    if num == 0:
        if ord(ar[b]) != symb:
            ans = min(ans, kek + 1)
        else:
            ans = min(ans, kek)
        return
    for i in range(a, b):
        if ord(ar[i]) != symb:
            kek += 1
    dfs(b, b + (b - a) // 2, num - 1, kek, symb + 1)
    for i in range(a, b):
        if ord(ar[i]) != symb:
            kek -= 1
    for i in range(b, b + (b - a)):
        if ord(ar[i]) != symb:
            kek += 1
    dfs(a, a + (b - a) // 2, num - 1, kek, symb + 1)


for __ in range(int(input())):
    n = int(input())
    ar = list(input())
    ans = 10 ** 9
    dfs(0, n // 2, log2(n), 0, 97)
    print(ans)