import sys
sys.setrecursionlimit(100000)
alphabets = "abcdefghijklmnopqrstuvwxyz"


def convert(s, a, b, ind):
    ch = alphabets[ind]
    # print("a", a, "b", b)
    if b - a == 1:
        if s[a] != ch:
            return 1
        else:
            return 0

    mid = (a + b) // 2
    c1, c2 = 0, 0
    for i in range(a, mid):
        if s[i] != ch:
            c1 += 1

    c1 += convert(s, mid, b, ind + 1)

    for i in range(mid, b):
        if s[i] != ch:
            c2 += 1

    c2 += convert(s, a, mid, ind + 1)
    return min(c1, c2)



for _ in range(int(input())):
    n = int(input())
    s = input()

    ans = convert(s, 0, n, 0)
    print(ans)