

def create_cases(data1, data2):
    cases = []
    answers = []
    data1 = data1.split('\n')[1:]
    data2 = data2.split('\n')
    for i in data1:
        if len(i) == 1:
            continue
        x = list(map(int, i.split()))
        cases.append(x)
    for i in data2:
        answers.append(list(map(int, i)))
    return cases, answers


def f(cases):
    answers = []
    for case in cases:
        answer = calc(case, 0)
        answers.append(answer)
    return answers

letters = 'abcdefghijklmnopqrstuvwxyz'

def calc(s, i):
    print(f'\n\n{s}\n{letters[i]}\n\n')
    if len(s) == 1:
        if s == letters[i]:
            return 0
        return 1
    
    mid = len(s) // 2
    cntl = mid - s.count(letters[i]) + calc(s[0:mid], i+1)
    cntr = mid - s.count(letters[i]) +  calc(s[mid:], i+1)
    print(f'\n\n{cntl}\n{cntr}\n\n')
    return min(cntl, cntr)




if __name__ == "__main__":
    n = int(input())
    cases = []
    while n > 0:
        input()
        cases.append(input())
        n -= 1
    answers = f(cases)
    for answer in answers:
        print(answer)