testcases = int(input())

def dfs(strs, prev):
    x = chr(ord(prev) + 1) 
    n = len(strs)
    if n == 1 and strs == x:
        return 0 
    if n == 1 :
        return 1 
    half = n // 2 
    firststr = strs[:half]
    secstr = strs[half:]
    flen = 0 
    slen = 0 
    for i in firststr:
        if i != x:
            flen += 1 
            
    for i in secstr:
        if i != x:
            slen += 1 
    return min( flen + dfs( strs[half:], x ) , slen + dfs( strs[:half], x )  )
    
for testcase in range(testcases):
    n = int(input())
    strs = input()
    if n == 1 and strs == "a":
        print(0)
        continue 
    if n == 1:
        print(1)
        continue 
    half = n // 2 
    firststr = strs[:half]
    secstr = strs[half:]
    #print(firststr)
    ans = n
    flen = 0 
    slen = 0 
    for i in firststr:
        if i != "a":
            flen += 1 
            
    for i in secstr:
        if i != "a":
            slen += 1 
    ans =  min( flen + dfs( strs[half:], "a" ) , slen + dfs( strs[:half], "a" ) )
    print(ans)
    
                    
        
        
        
        
        
        