def good(s, left, c, length):
    if length == 1 and s[left] == c:
        return 0
    elif length == 1:
        return 1
    else:
        ul = left + length//2
        count_left, count_right, c = length//2 - s[left : left + length//2].count(c),length//2 - s[ul : ul + length//2].count(c), chr(ord(c) +1)
        return min(good(s, left, c, length//2) + count_right, good(s, ul, c, length//2) + count_left)

t = int(input())
while t > 0:
    n = int(input())
    s = input()
    left, ch = 0, 'a'
    print(good(s, left, ch, n))
    t -= 1