def ans(arr , n , a):
    n = len(arr)
    #print("SLI: " , sLi , n , a)
    if(n == 1):
        if(arr[0] == a):
            #print("RETURNING BASE: 0" , arr , a)
            return 0 
        #print("RETURNING BASE: 1" , arr  ,a)
        return 1 
    h1 = 0 #0 to (n//2)-1 
    h2 = 0 #(n//2) to n 

    i = 0
    while(i<(n//2)):
        if(arr[i] != a):
            h1 += 1
        i += 1  
    while(i<n):
        if(arr[i] != a):
            h2 += 1 
        i+=1
      
    callOp1 = ans(arr[0:n//2] , n//2 , a+1)+h2
    callOp2 = ans(arr[n//2:n] , n//2 , a+1)+h1 
    #print("RETURING: " , min( (callOp1,callOp2)) , arr , a)
    return min((callOp1,callOp2)) 

for _ in range(int(input())):
    n = int(input()) 
    sLi = (input())
    arr = [] 
    for i in sLi:
        arr.append(ord(i)-96)
    print(ans(arr , n , 1))
    #print(arr)