def calc(l, r, c):
    if r - l == 1:
        return 0 if a[l] == c else 1
    mid = (l + r+1)//2
    cntl = (r-l)//2 - a[l:mid].count(c) + calc(mid, r, chr(ord(c) + 1))
    cntr = (r-l)//2 - a[mid:r].count(c) + calc(l, mid, chr(ord(c) + 1))
    return min(cntl, cntr)

t = int(input())
for i in range(t):
    n = int(input())
    a = input()
    print(calc(0, n, "a"))