from collections import *
import sys    
    
def ri():
    return int(input())
 
def rl():
    return list(map(int, input().split()))

import string
values = dict()
for index, letter in enumerate(string.ascii_lowercase):
   values[index+1] = letter


def solve(s,n,nb):
    letter=values[nb]
    if n==1:
        if s==letter:
            return 0
        else:
            return 1
    else:
        k=n//2
        ans1=0
        ans2=0
        for i in range(k):
            if s[i]!=letter:
                ans1+=1
        for i in range(k,n):
            if s[i]!=letter:
                ans2+=1
        return min(ans1+solve(s[k:],k,nb+1), ans2+solve(s[:k],k,nb+1))







t=ri()
for _ in range(t):
    n=ri()
    s=input()
    print(solve(s,n,1))


    
                
