def change_count(num, st, cur):
    if num == 1:
        if st == cur:
            return 0
        else:
            return 1
    else:
        mid = num // 2
        left = mid - st[:mid].count(cur)
        right = mid - st[mid:].count(cur)
        return min(left + change_count(mid, st[mid:], chr(ord(cur)+1)), right + change_count(mid, st[:mid], chr(ord(cur)+1)))

for i in range(int(input())):
    n = int(input())
    s = input()
    print(change_count(n, s, 'a'))
