#!/usr/bin/pypy3
def moves(s, l, r, p):
    count = 0
    for i in range(l, r):
        if s[i] != p:
            count += 1
    return count


def mkgd(s, l, r, p):
    if abs(l - r) == 1:
        if s[l] == p:
            return 0
        else:
            return 1
    mid = (l + r) // 2
    return min(moves(s, l, mid, p) + mkgd(s, mid, r, chr(ord(p) + 1)), moves(s, mid, r, p) + mkgd(s, l, mid, chr(ord(p) + 1)))


for _ in range(int(input())):
    n = int(input())
    s = str(input())
    ans = mkgd(s, 0, n, 'a')
    print(ans)
