def count(s , c , l , r):
    length = r-l+1
    for i in range(l, r+1):
        if s[i] == c:
            length -=1
    return length

def getMin(l,r,c,s):
    length = r-l+1
    if length == 1:
        if s[l] == c:
            return 0
        else:
            return 1
    else:
        nc = chr(ord(c)+1)
        mid = length // 2
        return min(count(s,c,l+mid, r) + getMin(l, l+mid-1, nc, s) , count(s,c,l,l+mid-1) + getMin(l+mid, r, nc, s))

t = int(input())
for i in range(t):
    n = int(input())
    s = input()
    print(getMin(0, n-1 ,'a' , s))