import sys
import math,bisect
from itertools import groupby,accumulate
from heapq import heapify,heappop,heappush
from collections import deque,Counter,OrderedDict
#input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
def neo(): return map(int,input().split())
def Neo(): return list(map(int,input().split()))
def fun(X,k):
    if len(X) == 0:
        return 0
    if len(X) == 1:
        return int(X[0] != k)
    m = len(X)//2
    L = X[:m]
    R = X[m:]
    return min(m - L.count(k) + fun(R,chr(ord(k)+1)),m - R.count(k) + fun(L,chr(ord(k)+1)))
for _ in range(int(input())):
    N = int(input())
    S = input()
    print(fun(S,'a'))
