from sys import stdin, setrecursionlimit, stdout
#setrecursionlimit(1000000) #use "python" instead of "pypy" to avoid MLE
from collections import deque
from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin
from heapq import heapify, heappop, heappush, heapreplace, heappushpop
def ii(): return int(stdin.readline())
def fi(): return float(stdin.readline())
def mi(): return map(int, stdin.readline().split())
def fmi(): return map(float, stdin.readline().split())
def li(): return list(mi())
def si(): return stdin.readline().rstrip()
def lsi(): return list(si())
mod=1000000007
res=['YES', 'NO']



def solve(l, r, x):
    if l==r:
        if ord(a[l])==x+97:
            return 0
        return 1
    cnt=cnt1=0
    m=(l+r)//2
    for i in a[l:m+1]:
        if ord(i)-97!=x:
            cnt+=1
    for i in a[m+1:r+1]:
        if ord(i)-97!=x:
            cnt1+=1

    return min(solve(m+1, r, x+1)+cnt, solve(l, m, x+1)+cnt1)


"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
###########################  C O D E  S T A R T S  H E R E  ###########################
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""


test=1
test_case=ii()
while test<=test_case:
    test+=1


    n=ii()
    a=lsi()
    print(solve(0, n-1, 0))