def problem1():
    x, y, z = sorted(list(map(int, input().split())))
    if y != z:
        print('NO')
        return
    print('YES')
    print(y, x, x)

def problem2():
    n = int(input())
    l = list(map(int, input().split()))
    s = set(l)
    d = {}
    for i in s:
        d[i] = 0
    a = []
    for i in l:
        if d[i] == 0:
            a.append(i)
            d[i] += 1
    print(*a)

def problem3():
    n = int(input())
    l = list(map(int,input().split()))
    l.append(-1)
    i = n - 1
    while i >= 0 and l[i] >= l[i+1]:
        i -= 1
    while i >= 0 and l[i] <= l[i+1]:
        i -= 1
    print(i+1)

def p4r(l, c, n):
    if n == 1:
        return 0 if l[0] == c else 1
    a = p4r(l[n//2:], chr(ord(c)+1), n//2) - l[:n//2].count(c)
    b = p4r(l[:n//2], chr(ord(c)+1), n//2) - l[n//2:].count(c)
    return n//2 + min(a,b)

def problem4():
    n = int(input())
    l = input().strip()
    print(p4r(l,'a', n))
    
cases = int(input())
for _ in range(cases):
    # problem1()
    # problem2()
    # problem3()
    problem4()