import sys
input = sys.stdin.readline
 
t = int(input())
letters = 'abcdefghijklmnopqrst'
 
for _ in range(t):
    b = int(input())
    a = input().rstrip()
    z = list(a)

    ans = [[] for x in range(b)]
    
    l = 2
    c = 0
    
    while True:
        length = max(1, b//l)
        for j in range(min(l,b)):
            let = letters[c]
            count = z[length*j: length*(j+1)].count(let)
            
            if length==1:
                if j % 2 ==0:
                    tt = j
                else:
                    tt = j - 1
                    
                count = min(1,z[length*tt: length*(tt+2)].count(let))
            
            for k in range(length):
                if j%2==0:
                    hh = j + 1
                else:
                    hh = j - 1
                
                if length > 1:
                    ans[length*hh + k].append(count)
                if length < 2:
                    #print(count, let, z[length*j: length*(j+1)])
                    ans[length*j + k].append(count)
                    
             
        #print(l,b) 
        if l > b:
            
            break
        c += 1
        l *= 2
        
    best = 99999999
    
    for el in ans:
        best = min(best, b - sum(el))
        
    print(best)