from sys import stdin

def good(l,s,e,c):
    n = e-s
    if n == 1:
        if l[s] == c:
            return 0
        else:
            return 1
    mid = (s+e)//2
    left = 0
    right = 0
    for x in range(s,mid):
        if l[x] == c:
            left += 1
    for x in range(mid,e):
        if l[x] == c:
            right += 1
    return min(n//2-left+good(l,mid,e,c+1), n//2-right+good(l,s,mid,c+1))

for case in range(int(stdin.readline())):
    n = int(stdin.readline())

    s = list([ord(x)-97 for x in stdin.readline().strip()])

    print(good(s,0,n,0))
