def calc(a,c):
    if len(a) == 1:
        return int(c != a[0])

    mid = int(len(a)/2)

    leftside = mid - a[0:mid].count(c) + calc(a[mid:len(a)],chr(ord(c)+1))

    rightside = mid - a[mid:len(a)].count(c) + calc(a[0:mid],chr(ord(c)+1))

    return min(leftside,rightside)

t = int(input())
for _ in range(0,t):
    input()
    a = input()
    print(calc(a,'a'))
