t = int(input())

def getFreq(arr):
    n = len(arr)
    freq = [ [0 for _ in range(n)]  for i in range(26)]
    
    for i in range(n):
        indx = ord(arr[i])-ord("a")
        if i == 0:
            # smth
            freq[indx][i] = 1
        else:
            # smth
            for j in range(26):
                if j == indx:
                    freq[j][i] = 1 + freq[j][i-1]
                else:
                    freq[j][i] = freq[j][i-1]
    return freq
    


def makeItGood(s, c, f, start, end):
    # print()
    # print("called", s, "with", start, ":", end, "for", c)
    indx = ord(c) - ord('a')
    n = end - start + 1
    
    if n == 1:
        if s[start] == c:
            return 0
        else:
            return 1
    
    mid = (start + end) // 2 + 1
    freqInLeft = f[indx][mid-1]
    if start != 0:
        freqInLeft -= f[indx][start-1]
    freqInRight = f[indx][end]-freqInLeft
    if start != 0:
        freqInRight -= f[indx][start-1]
        
    # print(freqInLeft, freqInRight, "freq of", c)
    
    makeLeftGood = makeItGood(s, chr(indx+ord('a')+1), f, start, mid-1)
    makeRightGood = makeItGood(s, chr(indx+ord('a')+1), f, mid, end)
    a = n//2-freqInLeft
    b = n//2-freqInRight

    return min(a + makeRightGood, b + makeLeftGood)
    
def solve(arr):
    freq = getFreq(arr)
    n  = len(arr)
    return makeItGood(arr, "a" ,freq, 0, n-1)
    

while t > 0:
    n = int(input())
    s = input()
    # arr = list(map(int, input().split()))
    # x, y, z = map(int, input().split())
    print(solve(s))
    t -= 1