char = "abcdefghijklmnopqrstuvwxyz"


def count(start, end, i):
    return s[start : end + 1].count(char[i])


def check(s, low, high, i):
    if low == high:
        if s[low] != char[i]:
            return 1
        else:
            return 0
    mid = (low + high) // 2
    l_count = count(low, mid, i)
    r_count = count(mid + 1, high, i)
    #print(l_count,r_count,char[i])
    if l_count == r_count:
        return (
            mid
            - low
            + 1
            - l_count
            + min(check(s, mid + 1, high, i + 1), check(s, low, mid, i + 1))
        )
    elif l_count > r_count:
        ans = mid - low + 1 - l_count
        #print("low , high ",low,mid,"l_count ",l_count,"ans is ",ans)
        return ans + check(s, mid + 1, high, i + 1)
    else:
        ans = high - (mid + 1) + 1 - r_count
        #print("low , high ",mid+1,high,"r_count ",r_count,"ans is ",ans)
        return ans + check(s, low, mid, i + 1)


t = int(input())
while t:
    t -= 1
    n = int(input())
    s = input()
    print(check(s, 0, n - 1, 0))

