def g(a, n, k):
    s = 0
    for i in range(n):
        if a[i] != k:
            s += 1
    return s

def f(a, n, k):
    if n == 1:
        if a[0] == k:
            return 0
        else:
            return 1
    a1 = a[:n//2]
    a2 = a[n//2:]
    ans = min(f(a1, n//2, k+1) + g(a2, n//2, k),
               f(a2, n//2, k+1) + g(a1, n//2, k))
    #print(a, n, k, '\n', ans, '\n======\n')
    return ans



t = int(input())
for _ in range(t):
    n = int(input())
    s = input()
    a = [ord(c) - ord('a') for c in s]
    #print(a)
    #print()
    
    '''n1 = n; k = 0
    while n1 > 1:
        n1 //= 2
        k += 1
    print(k)'''
    
    ans = f(a, n, 0)
    print(ans)