def count_c(s, c):
    count = 0
    for character in s:
        if character != c:
            count += 1
    return count

def count_to_good(s, c):
    n = len(s)
    if (n==1):
        if s == c:
            return 0
        else:
            return 1

    c_in_first_half = count_c(s[:n//2], c) + count_to_good(s[n//2:], chr(ord(c) + 1))
    c_in_second_half = count_c(s[n//2:], c) + count_to_good(s[:n//2], chr(ord(c) + 1))
    return min(c_in_first_half, c_in_second_half)



if __name__ == "__main__":
    for _ in range(int(input())):
        n = int(input())
        s = input()
        print(count_to_good(s, 'a'))

        # print(count_c(s, 'a'))
