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

for z in range(int(input())):

    n = int(input())
    s = input()
    print(F(0,n,'a'))