def cgood(s, l, c) ->int :
    if l == 1 :
        if s[0] == c :
            return 0
        else :
            return 1
    fh = s[0:l//2]
    sh = s[l//2:]
    fhc = 0
    shc = 0
    for i in fh :
        if i == c :
            fhc += 1
    for i in sh :
        if i == c :
            shc += 1
    # print(fh, fhc, sh, shc)
    return min(l//2 - fhc + cgood(sh, l//2, chr(ord(c)+1)), l//2 - shc + cgood(fh, l//2, chr(ord(c)+1)))


t = int(input())
for tc in range(t):
    l = int(input())
    s = input()
    print(cgood(s, l, 'a'))