from collections import Counter


def solve(s, c='a'):
    if len(s) == 1:
        return int(s != c)
    count_l = Counter(s[:len(s) // 2])
    count_r = Counter(s[len(s) // 2:])
    # if count_l[c] > count_r[c]:
    #     diff = len(s) // 2 - count_l[c] + solve(s[len(s) // 2:], chr(ord(c)+1))
    # elif count_l[c] < count_r[c]:
    #     diff = len(s) // 2 - count_r[c] + solve(s[:len(s) // 2], chr(ord(c)+1))
    # else:
    diff = min(
            len(s) // 2 - count_r[c] + solve(s[:len(s) // 2], chr(ord(c) + 1)),
            len(s) // 2 - count_l[c] + solve(s[len(s) // 2:], chr(ord(c) + 1))
        )
    return diff





for _ in range(int(input())):
    n = range(int(input()))
    s = input()
    print(solve(s))



