# cook your dish here
def cost(str, n = 97, same = False):
    if same:
        c = 0
        for i in str:
            if ord(i) != n:
                c += 1
        return c
    w = len(str)
    if w == 1:
        if ord(str[0]) == n:
            return 0
        else:
            return 1
    else:
        a = cost(str[:w//2], n+1) + cost(str[w//2:], n, same = True)
        b = cost(str[:w//2], n, same = True) + cost(str[w//2:], n+1)
        return min(a, b)
    
t = int(input())


for q in range(t):
    n = int(input())
    str = input()
    print(cost(str))