def cnt(s, c):
    x = 0
    for i in s:
        if i != c:
            x += 1
    return x

def search(s, n, cho):
    c = chr(cho)
    if n == 1:
        return 0 if s[0] == c else 1
    m = n // 2
    s1 = s[:m]
    s2 = s[m:]
    x = cnt(s1, c) + search(s2, m, cho+1)
    y = search(s1, m, cho+1) + cnt(s2, c)
    return min(x, y)

t = int(input())

for _ in range(t):
    n = int(input())
    s = input()
    #print(s)
    l = 0
    r = n
    moves = 0
    cho = ord('a')
    print(search(s, n, cho))
    continue
    while r - l > 1:
        ch = chr(cho)
        m = (l + r) // 2
        x = cnt(s, l, m, ch)
        y = cnt(s, m, r, ch)
        lng = m - l
        print(f"ch={ch}, l={l}, m={m}, r={r}, x={x}, y={y}")
        if x > y:
            moves += lng - x
            l = m
        else:
            moves += lng - y
            r = m
        cho += 1
        print(f"l={l}, moves={moves}, ch=>{chr(cho)}")
    else:
        if s[l] != chr(cho):
            moves += 1
    print(moves)
