from math import ceil
def mlt(): return map(int, input().split())


def rec(st, cr):
    if len(st) == 1:
        return int(st[0] != cr)

    a = 0
    mid = len(st)//2
    for n in range(mid):
        if st[n] != cr:
            a += 1

    b = 0
    for n in range(mid, len(st)):
        if st[n] != cr:
            b += 1
    y = rec(st[mid:], chr(ord(cr)+1))+a
    x = b+rec(st[:mid], chr(ord(cr)+1))

    return min(x, y)


for _ in range(int(input())):
    input()
    print(rec(input(), 'a'))
