import sys
import bisect as bi
import math
import string
from collections import defaultdict as dd
input=sys.stdin.readline
sys.setrecursionlimit(10**6)
def cin():
    return map(int,sin().split())
def ain():            
    return list(map(int,sin().split()))
def sin():
    return input()
def inin():
    return int(input())
d="abcdefghijklmnopqrstuvwxyz"
def solve(s,n,ans,c):
    if(n==1):
        if(ord(s)-ord('a')==c):return 0
        else:return 1
    c1=s[0:n//2].count(d[c])
    c2=s[n//2:n].count(d[c])
    s1=s[n//2:n];s2=s[0:n//2]
    ans+=min((solve(s1,n//2,ans,c+1)+n//2-c1),(solve(s2,n//2,ans,c+1)+n//2-c2))
    return ans
for _ in range(inin()):
    n=inin();s=sin().strip()
    print(solve(s,n,0,0))
    