def make(s, n, a):
    #print(s, end='')
    if n==1:
        # return 0
        if s[0] != chr(ord('a')+a):
            return 1
        else:
            return 0
    res = 0
    N=int(n/2)
    h1,h2 = s[:N].count(chr(ord('a')+a)),s[N:].count(chr(ord('a')+a)) 
    h1t = h1>h2
    if h1==h2:
        q1,q2 = s[:N].count(chr(ord('a')+a+1)),s[N:].count(chr(ord('a')+a+1))
        h1t = q1<q2
    if h1t :
        #print((N)-h1)
        return ((N)-h1) + make(s[N:],N,a+1)
    else:
        #print((N)-h2)
        return ((N)-h2) + make(s[:N],N,a+1)



for _ in range(int(input())):
    n = int(input())
    s = input()
    print(make(s,n,0))

