from sys import stdin

def calc(s, c):
    if len(s) == 1:
        return int(s[0] != c)
    m = len(s) // 2
    cntl = calc(s[m:], chr(ord(c)+1))
    cntl += len(s) / 2 - s[0:m].count(c)
    cntr = calc(s[0:m], chr(ord(c)+1))
    cntr += len(s) / 2 - s[m:].count(c)
    return int(min(cntl, cntr))

if __name__ == '__main__':
    lines = stdin.readlines()
    t = int(lines[0])

    for i in range(2, len(lines), 2):
        s = lines[i].rstrip('\r\n')
        print(calc(s, 'a'))