from sys import *

# stdin = open('input.txt', 'r')

def num_good_string(s, c):
    if len(s) <= 0:
        return 0
    if len(s) == 1:
        if s[0] == c:
            return 0
        return 1

    middle_point = int(len(s)/2)

    first_sec = cost_replace_char(s[:middle_point], c) + num_good_string(s[middle_point:], chr(ord(c) + 1))
    second_sec = num_good_string(s[:middle_point], chr(ord(c) + 1)) + cost_replace_char(s[middle_point:], c)
    return min(first_sec, second_sec)

def cost_replace_char(s, c):
    cost = 0
    for a in s:
        if a != c:
            cost += 1
    return cost

def solve_case(t):
    n = int(stdin.readline())
    s = stdin.readline().rstrip()
    result = num_good_string(s, 'a')

    print(result)

def main():
    T = int(stdin.readline())

    for t in range(T):
        solve_case(t)

main()
