import sys
import math
import heapq
from collections import defaultdict, deque
from decimal import *
def r():
    return int(input())
def rm():
    return map(int,input().split())
def rl():
    return list(map(int,input().split()))

'''D a-Good String'''
def givegood(a,check):
    if len(a)==1:
        if a[0]==check:
            return 0
        else:
            return 1
    lcheck=0
    rcheck=0
    n=len(a)
    for i in range(n//2):
        if a[i]!=check:
            lcheck+=1
    for i in range(n//2,n):
        if a[i]!=check:
            rcheck+=1
    la=a[:n//2]
    ra=a[n//2:]
    lans=givegood(ra,chr(ord(check)+1))
    rans=givegood(la,chr(ord(check)+1))
    return min(lcheck+lans,rcheck+rans)

for _ in range(r()):
    n=r()
    a=input()
    print(givegood(a,'a'))