import sys
input = sys.stdin.readline
def rec(start,end,ind):
    if start == end:
        if l[start] == o[ind]:
            return 0

        return 1

    mid = (start+end)//2
    ans1 = 0
    ans2 = 0
    for i in range(start,mid+1):
        if l[i] != o[ind]:
            ans1 += 1

    for i in range(mid+1,end+1):
        if l[i] != o[ind]:
            ans2 += 1

    r = min(ans1,ans2)
    # if ans1 <= ans2:
    pol1 = r+rec(mid+1,end,ind+1)

    # else:
    pol2 = r+rec(start,mid,ind+1)
    pol = min(pol1,pol2)

    return pol

for _ in range(int(input())):
    n = int(input())
    s = input()
    l = []
    for i in range(n):
        l.append(s[i])

    o = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
    ans = rec(0,n-1,0)
    sys.stdout.write(str(ans)+"\n")