t = int(raw_input())

def freq(s,c):
    count = 0
    for x in s:
        count += (x == c)
    return count

def solve(n,s,c):
    if n == 1:
        return int(s != c)

    fst_half = s[:n/2]
    snd_half = s[n/2:]

    fst_half_c_freq = freq(fst_half, c)
    snd_half_c_freq = freq(snd_half, c)

    next_c = chr(ord(c)+1)

    if fst_half_c_freq == snd_half_c_freq:
        # c-good string is first half
        fst_half_solve = n/2 - fst_half_c_freq + solve(n/2, snd_half, next_c)
        # c-good string is second half
        snd_half_solve = n/2 - snd_half_c_freq + solve(n/2, fst_half, next_c)

        return min(fst_half_solve, snd_half_solve)
    else:
        if fst_half_c_freq > snd_half_c_freq:
            return n/2 - fst_half_c_freq + solve(n/2, snd_half, next_c)
        else:
            return n/2 - snd_half_c_freq + solve(n/2, fst_half, next_c)

for it in xrange(t):
    n = int(raw_input())
    s = raw_input()

    print(solve(n,s,'a'))