import math
t = int(input())

def solve(ch, arr, l):
    ch1 = chr(ord(ch) + 1)
    if(l == 1):
        return 0 if ch==arr[0] else 1

    t1=solve(ch1, arr[l//2:], l//2)
    t2=(l//2-arr[:l//2].count(ch))
    t3=solve(ch1, arr[:l//2], l//2)
    t4=(l//2-arr[l//2:].count(ch))
    return min(t1+t2, t3+t4)


for i in range(t):
    n =int(input())
    a = list(input())
    # print(a[:(n//2)])
    # print(a[n//2:])
    print(solve('a', a, n))
