t = int(input())
while t>0:
    t-=1
    n = int(input())
    s = input()
    
    def getVal(low, high, ch):
        if low == high:
            return int(s[low] != chr(ch+97))
            
        half = (high-low+1) >> 1
        mid = low + half
        
        return min(getVal(low,mid-1, ch+1) + half - s[mid:high+1].count(chr(97+ch)), getVal(mid, high, ch+1) + half-s[low:mid].count(chr(ch+97)))
        
    print(getVal(0, n-1, 0))