def task_1(s, target) :
    return len(s)-s.count(target)
def main_task(start, end, target) :
    if start+1 == end :
        if s[start] == target :
            return 0
        else :
            return 1
    m = (start+end)//2
    a = task_1(s[start:m], target)+main_task(m, end, chr(ord(target)+1))
    b = task_1(s[m:end], target)+main_task(start, m, chr(ord(target)+1))
    return min(a, b)
for i in range(int(input())) :
    n = int(input())
    s = input()
    print(main_task(0, n, 'a'))