def fn(txt, c, n):
    if not txt:
        return 0
    f1, f2 = txt[:n/2], txt[n/2:]
    if n%2:
        return 1-f2.count(c), "R"
    f1c, f2c = f1.count(c), f2.count(c)
    if f1c > f2c:
        return n/2 - f1c, "L"
    if f2c > f1c:
        return n/2 - f2c, "R"
    return n/2 - f1c, "LR"

def count(txt, char):
    if not txt:
        return 0
    n = len(txt)
    #print "txt", txt, "char", char, "n", n
    ct, pos = fn(txt, chr(char), n)
    ans = ct
    if pos == "L":
        ans += count(txt[n/2:], char+1)
    elif pos == "R":
        ans += count(txt[:n/2], char+1)
    else:
        ans += min(count(txt[n/2:], char+1), count(txt[:n/2], char+1))
    return ans

for _ in xrange(input()):
    n = input()
    txt = raw_input()
    print count(txt, 97)
    
