def getGood(left, right, ch, string):
    num = int(right - left)
    mid = int((left + right) / 2)
    changeL = 0
    changeR = 0
    if num == 1:
        return int(string[left] != ch)
    for i in range(num):
        if i < num / 2 and string[left + i] != ch:
            changeL += 1
        if i >= num / 2 and string[left + i] != ch:
            changeR += 1
    newCh = chr(ord(ch) + 1)
    return min(changeL + getGood(mid, right, newCh ,string), changeR + getGood(left, mid, newCh,string))
times = input()
for i in range(int(times)):
    num = input()
    string = input()
    print(getGood(0,int(num),'a',string))