from sys import stdin
from collections import deque

def fun(l,r,ans,ch):
    global maxi,s
    ch = chr(ch)
    if l == r-1:
        if s[l] != ch:
            ans += 1
        maxi = min(maxi,ans)
        return
    ans1 = ans
    mid = (l+r)//2
    for j in range(l,mid):
        if s[j] != ch:
            ans += 1
    for j in range(mid,r):
        if s[j] != ch:
            ans1 += 1
    fun(mid,r,ans,ord(ch)+1)
    fun(l,mid,ans1,ord(ch)+1)

for _ in range(int(stdin.readline())):
    n = int(stdin.readline())
    s = stdin.readline()
    maxi = 10**10
    fun(0,n,0,97)
    print(maxi)
