def calc(string,c):
    char = chr(c)
    if len(string) == 1:
        #1 if not same
        return 1 if string[0] != char else 0
    #second condition
    tot_chars = len(string)//2
    cntl = tot_chars-string[0:tot_chars].count(char) + calc(string[tot_chars:],c+1)
    cntr = tot_chars - string[tot_chars:].count(char) +  calc(string[:tot_chars],c+1)
    return min(cntl,cntr)
    
        
        
        
t = int(input())
for i in range(t):
    n = int(input())
    s = input()
    print(calc(s,ord("a")))
    