def cost(lst, n, ch):
    if n == 1:
        if lst[0] == ch:
            return 0
        return 1
    else:
        a1 = lst[:n // 2]
        a2 = lst[n // 2:]
        return min((n // 2 - a1.count(ch)) + cost(a2, n // 2, chr(ord(ch) + 1)),
                   (n // 2 - a2.count(ch)) + cost(a1, n // 2, chr(ord(ch) + 1)))


for _ in range(int(input())):
    m = int(input())
    a = list(input())
    print(cost(a, m, "a"))
