from sys import stdin
def calcgood(l, r, c, sta):
    slices = sta[l:r]
    half = (l + r) // 2
    res = 0
    if l == r - 1:
        if sta[l] == c:
            return 0
        return 1
    fh = 0
    sh = 0
    for i in range(0, len(slices) // 2):
        if slices[i] ==  c:
            fh += 1
    sh = slices.count(c) - fh
    res = min((len(slices) // 2) - fh + calcgood(half, r, chr(ord(c) + 1), sta), (len(slices) // 2) - sh + calcgood(l, half, chr(ord(c) + 1), sta))
    return res
for _ in range(int(stdin.readline())):
    length = int(stdin.readline())
    string = stdin.readline().strip()
    print(calcgood(0, length, "a", string))
