def calc(s, letter):
    return len(s)-s.count(letter)

def find(s, letter):
    if len(s) == 1:
        return 1-int(s==letter)
    return min([calc(s[:len(s)//2], letter)+find(s[len(s)//2:], chr(ord(letter)+1)), calc(s[len(s)//2:], letter)+find(s[:len(s)//2], chr(ord(letter)+1))])

t = int(input())
while(t):
    t -= 1
    n = int(input())
    s = input()
    print(find(s, "a"))