import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log
from collections import defaultdict
from bisect import bisect_left as bl, bisect_right as br
from collections import Counter

ip = lambda : int(stdin.readline())
inp = lambda: map(int,stdin.readline().split())

def check(st,end,idx):
    cnt = 0
    for i in range(st,end):
        if s[i] != ch[idx]:
            cnt += 1
    return cnt

def solve(st,end,idx):
    if st+1 == end:
        if s[st] != ch[idx]:
            return 1
        else:
            return 0 
    else:
        alp = ch[idx]
        mid = (st+end)//2
        ch1 = check(mid,end,idx)+solve(st,mid,idx+1)
        ch2 = check(st,mid,idx)+ solve(mid,end,idx+1)
        return min(ch1,ch2)

t = ip()
for _ in range(t):
    n = ip()
    s = input()
    s = list(s)
    ch = 'abcdefghijklmnopqrstuvwxyz'
    ch = list(ch)
    ans = solve(0,n,0)
    print(ans)
    
              
    
        
        
        

        
    
                
        

