t = int(input())

def calc(l, r, c):
    if r-l == 1:
        if s[l] == c:
            return 0
        else:
            return 1
    m = (l+r)//2
    nc = chr(ord(c)+1)
    cnt1 = (r-l)//2-s[l:m].count(c)+calc(m, r, nc)
    cnt2 = (r-l)//2-s[m:r].count(c)+calc(l, m, nc)
    return min(cnt1, cnt2)

for _ in range(t):
    n = int(input())
    s = str(input())
    print(calc(0, n, 'a'))
