
def minCost(l, r, c):
    cost = 0
    for i in range(l-1, r):
        if s[i] != c:
            cost += 1
    return cost


def minChar(l, r, c):

    if l==r:
        if s[l-1]==c:
            return 0
        else:
            return 1

    mid = (l+r)//2

    return min(minCost(l, mid, c)+minChar(mid+1, r, chr(ord(c)+1)), minChar(l, mid, chr(ord(c)+1))+minCost(mid+1, r, c))


for _ in range(int(input())):
    n = int(input())
    s = input()
    print(minChar(1, n, 'a'))
