from __future__ import print_function, division
from sys import stdin, stdout
from fractions import gcd
from math import *
from collections import *
from operator import itemgetter, mul
from functools import reduce

rstr = lambda: stdin.readline().strip()
rstrs = lambda: [str(x) for x in stdin.readline().split()]
rint = lambda: int(stdin.readline())
rints = lambda: [int(x) for x in stdin.readline().split()]
arr_2d = lambda n: [rints() for i in range(n)]
out = []


def f(be, en, ch):
    if en - be == 1:
        return s[be] == ch

    mid = (be + en) >> 1

    v1 = s[be:mid].count(ch)
    v2 = s[mid:en].count(ch)

    return max(v2 + f(be, mid, chr(ord(ch) + 1)), v1 + f(mid, en, chr(ord(ch) + 1)))


for _ in range(int(input())):
    n, s = rint(), rstr()
    out.append(n - f(0, n, 'a'))

print('\n'.join(map(str, out)))
