s = ""

def not_equal_count(start, end, c):
    count = 0
    for i in range(start, end):
        if s[i] != c:
            count += 1
    return count

def good_string(start, end, c):
    if end - start == 1:
        if s[start] == c:
            return 0
        else:
            return 1
    else:
        a = good_string(start, start + int((end-start)/2), chr(ord(c) + 1)) + not_equal_count(start + int((end-start)/2), end, c)
        b = good_string(start + int((end-start)/2), end, chr(ord(c) + 1)) + not_equal_count(start, start + int((end-start)/2), c)
        return min(a, b)


n = int(input())
for i in range(n):
    l = int(input())
    s = input()

    count = good_string(0, l, 'a')
    print(count)
