#
#    ------------------------------------------------
#           ____          _     Generatered using
#          / ___|        | |
#         | |    __ _  __| | ___ _ __  ______ _
#         | |   / _` |/ _` |/ _ \ '_ \|_  / _` |
#         | |__| (_| | (_| |  __/ | | |/ / (_| |
#          \____\____|\____|\___|_| |_/___\____|
#
#      GNU Affero General Public License v3.0
#    ------------------------------------------------
#    Author   : prophet
#    Created  : 2020-07-17 11:49:48.868410
#    UUID     : QuSphZLA3DzXj3i0
#    ------------------------------------------------
#
production = True

import sys, math, collections

def input(input_format = 0, multi = 0):

    if multi > 0: return [input(input_format) for i in range(multi)]
    else:
        next_line = sys.stdin.readline()[:-1]

        if input_format >= 10:
            use_list = False
            input_format = int(str(input_format)[-1])
        else: use_list = True

        if input_format == 0: formatted_input = [next_line]
        elif input_format == 1: formatted_input = list(map(int, next_line.split()))
        elif input_format == 2: formatted_input = list(map(float, next_line.split()))
        elif input_format == 3: formatted_input = list(next_line)
        elif input_format == 4: formatted_input = list(map(int, list(next_line)))
        elif input_format == 5: formatted_input = next_line.split()
        else: formatted_input = [next_line]

        return formatted_input if use_list else formatted_input[0]

def out(output_line, output_format = 0, newline = True):

    formatted_output = ""

    if output_format == 0: formatted_output = str(output_line)
    elif output_format == 1: formatted_output = " ".join(map(str, output_line))
    elif output_format == 2: formatted_output = "\n".join(map(str, output_line))

    print(formatted_output, end = "\n" if newline else "")

def log(*args):
    if not production:
        print("$$$", end = "")
        print(*args)

enu = enumerate

ter = lambda a, b, c: b if a else c

ceil = lambda a, b: -(-a // b)

def mapl(iterable, format = 0):
    
    if format == 0: return list(map(int, iterable))
    elif format == 1: return list(map(str, iterable))
    elif format == 2: return list(map(list, iterable))
#
#   >>>>>>>>>>>>>>> START OF SOLUTION <<<<<<<<<<<<<<
#

a = []
w = dict()

def f(l ,r, c):
    return w[c][r] - w[c][l]

def b(l, r, c):
    if r - l == 1:
        return ter(a[l] == c, 0, 1)
    m = l + ((r - l) >> 1)
    h1 = a[l:m]
    h2 = a[m:r]

    t1 = f(l, m, c)
    t2 = f(m, r, c)

    la = m - l
    k1 = la - t1
    k2 = la - t2

    log(c, h1, k1, t1, l, m)
    log(c, h2, k2, t2, m, r)

    nc = chr(ord(c) + 1)

    ee = min(k1 + b(m, r, nc), k2 + b(l, m, nc))

    log(l, r, ee, k1, k2)
    log("")

    return ee


def solve():
    global a
    global w

    n = input(11)
    a = input(3)

    u = [chr(i) for i in range(97, 97 + 26)]
    for i in u:
        w[i] = [0]
        for j in a:
            if j == i:
                w[i].append(w[i][-1] + 1)
            else:
                w[i].append(w[i][-1])
        w[i].append(w[i][-1])

    log(a)

    for i, j in w.items():
        if i == "e":
            break
        log(i, j)

    out(b(0, n, "a"))
    log("")
    return


for i in range(input(11)): solve()
# solve()

#
#   >>>>>>>>>>>>>>>> END OF SOLUTION <<<<<<<<<<<<<<<
#
