def func(i, count, l):
    if count == 1:
        if s[i] == alf[l]:
            return 0
        else:
            return 1
    if (i, count // 2, l + 1) not in dict:
        dict[(i, count // 2, l + 1)] = func(i, count // 2, l + 1)

    if (i + count // 2, count // 2, l + 1) not in dict:
        dict[(i + count // 2, count // 2, l + 1)] = func(i + count // 2, count // 2, l + 1)
    first = dict[(i, count // 2, l + 1)]
    second = dict[(i + count // 2, count // 2, l + 1)]


    for el in range(i, i + count // 2):
        if s[el] != alf[l]:
            second += 1
    for el in range(i + count // 2, i + count):
        if s[el] != alf[l]:
            first += 1
    return min(first, second)


alf = "abcdefghijklmnopqrstuvwxyz"
t = int(input())
s = []
for _ in range(t):
    dict = {}
    n = int(input())
    s = list(input())
    print(func(0, n, 0))