import math

letters = {1:"a", 2:"b", 3:"c", 4:"d", 5:"e", 6:"f", 7:"g", 8:"h", 9:"i", 10:"j", 11:"k", 12:"l", 13:"m", 14:"n", 
           15:"o", 16:"p", 17:"q", 18:"r", 19:"s", 20:"t", 21:"u", 22:"v", 23:"w", 24:"x", 25:"y", 26:"z"}

def allc(ss, c):
    count = 0
    for letter in ss:
        if letter!=c:
            count += 1 
    return count

def func(ss):
    length = len(ss)
    c = letters[int(math.log(n//length,2)+1)]
    if length==1:
        return allc(ss,c)
    else:
        return min(func(ss[:length//2])+allc(ss[length//2:],c), func(ss[length//2:])+allc(ss[:length//2],c))

t = int(input())
for _ in range(t):
    n = int(input())
    string = input()
    print(func(string))