import time
from collections import deque 

def inpt():
    return int(input())
def inpl():
    return list(map(int,input().split()))
def inpm():
    return map(int,input().split())
    
def change(s,i):

    ss=chr(ord('a')+i)
    #print(s,i,ss)
    return sum([j!=ss for j in s])

def get(s,i):
    n=len(s)
    if n==1:
        return  1 if s!=chr(ord("a")+i) else 0
    return min(change(s[:n//2],i)+get(s[n//2:],i+1) , change(s[n//2:],i) + get(s[:n//2],i+1))
def solve():
    n = inpt()
    s = input()
    print(get(s,0))
    return 
    
    
def main():
    #start_time=time.time()
    m=10**9+7
    t = int(input())
    while(t):
        t-=1
        solve()
        
    
    #print('Time Elapsed = ',time.time()-start_time," seconds")
if __name__ == "__main__":
    main()
    