global ans
ans = []

def printer_rec(s,cost,character):
    l = len(s)
    fh_cost = sh_cost = 0
    for i in range(l):
        if(s[i]!=character):
            if(i<int(l/2)):
                fh_cost +=1
            else:
                sh_cost+=1

    # print(cost,fh_cost,s[:int(l/2)],sh_cost,s[int(l/2):])
    character = chr(ord(character)+1)
    temp = s[:int(l/2)]
    if(len(temp)>=1):
        # print(temp)
        # print(s[int(l/2):])
        printer_rec(temp,cost+sh_cost,character)
        printer_rec(s[int(l/2):],cost+fh_cost,character)
    else:
        # print(temp,s[int(l/2):])
        ans.append(cost+sh_cost)
        ans.append(cost+sh_cost)

    
    
        
t = int(input())
for i in range(t):
    global inp_len
    inp_len = int(input())
    s = str(input())
    printer_rec(s,0,'a')
    print(min(ans))
    ans = []