stlst = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
def minim(s , n, lent):
    c = stlst[n-1]
    if lent==1:
        if s==c:
            return 0
        else:
            return 1
            
    lent = lent//2
    s1 = s[:lent]
    s2 = s[lent:]
    
    c1 = 0
    c2 = 0
    for j in range(lent):
        if s1[j] == c:
            c1 +=1
        if s2[j] == c:
            c2+=1
            
    c1 = lent - c1
    c2 = lent - c2
    
    return(min(c1+minim(s2, n+1, lent), c2+minim(s1, n+1, lent)))




for i in range(int(input())):
    n = int(input())
    #ar = list(map(int, input().split()))
    st = input()
    print(minim(st, 1, n))
    