
    
import sys, threading
sys.setrecursionlimit(10**6)
threading.stack_size(10**6)  # new thread will get stack of such size

def main():
    def findMinCost(s,targetChar):
        if len(s)==1:
            return int(s[0]!=targetChar)
        mid=len(s)//2
        leftCost=sum(c!=targetChar for c in s[:mid])+findMinCost(s[mid:],chr(ord(targetChar)+1))
        rightCost=sum(c!=targetChar for c in s[mid:])+findMinCost(s[:mid],chr(ord(targetChar)+1))
        return min(leftCost,rightCost)
    
    t=int(input())
    for _ in range(t):
        _,s=int(input()),input()
        print(findMinCost(s,"a"))

threading.Thread(target=main).start()