t = int(input())
alph = "abcdefghijklmnopqrstuvwxyz"

def sim(s, it):
    
    if len(s) == 1:
        if s == alph[it]:
            return 0
        else:
            return 1
    
    l = s[:len(s)//2]
    r = s[len(s)//2:]
    sc1 = 0
    sc2 = 0
        
    for i in l:
        if i != alph[it]:
            sc1 += 1
            
    for i in r:
        if i != alph[it]:
            sc2 += 1
            
    return min(sc1+sim(r, it+1), sc2+sim(l, it+1))

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