t = int(input())
while t>0:
    t-=1
    n = int(input())
    s = input()
    
    def countFreq(s,ch):
        fq = 0
        for i in range(len(s)):
            if s[i] == ch:
                fq += 1
        return fq
    
    def calcGood(s,ch,cnt):
        if len(s) == 1:
            if s[0] != ch:
                return cnt+1
            return cnt
        
        md = len(s)//2
        s1 = s[:md]
        s2 = s[md:]
        f1 = countFreq(s1,ch)
        f2 = countFreq(s2,ch)
        
        if f1>f2:
            cnt += len(s1) - f1
            ch = chr(ord(ch) + 1)
            return calcGood(s2,ch,cnt)
        elif f2>f1:
            cnt += len(s2) - f2
            ch = chr(ord(ch) + 1)
            return calcGood(s1,ch,cnt)
        else:
            cnt += len(s2)- f2
            ch = chr(ord(ch) + 1)
            return min(calcGood(s2,ch,cnt),calcGood(s1,ch,cnt))
    
    ans = calcGood(s,'a',0) 
    print(ans)
            