
alphabet = list("abcdefghijklmnopqrstuvwxyz")


def query(index, string):
    if len(string) == 1:
        if alphabet[index] == string:
            return 0
        else:
            return 1
    else:
        n = len(string)
        fast = string[:n//2]
        second = string[n//2:]
        cnt_fast = 0
        cnt_second = 0
        for i in range(n//2):
            if alphabet[index] != fast[i]:
                cnt_fast += 1
        for i in range(n//2):
            if alphabet[index] != second[i]:
                cnt_second += 1
        return min(cnt_fast+query(index+1, second), cnt_second+query(index+1, fast))


def solve():
    n = int(input())
    s = input()
    ans = query(0, s)
    print(ans)
    return


def main():
    t = int(input())
    for i in range(t):
        solve()
    return


if __name__ == "__main__":
    main()

