def function(length,s,l):
    if length == 1:
        if l[0] != s:
            return 1
        else:
            return 0
    else:
        length = int(length/2)
        left = length - l[0:length].count(s) + function(length,chr(ord(s)+1),l[length:2*length])
        right = length - l[length:2*length].count(s) + function(length,chr(ord(s)+1),l[0:length])
        return min(left,right)

for _ in range(int(input())):
    str_length = int(input())
    string = input()

    ans = function(str_length,'a',string)
    print(ans)
