def main():
    c = "a"
    number = int(input())
    for i in range(number):
        length = int(input())
        string = input()
        print(minimum_number(string, length, c))

def minimum_number(string, length, c):
    if length == 1:
        if string == c:
            return 0
        else:
            return 1
    else:
        half = length // 2
        first = string[:half]
        last = string[half:]
        
        aux = chr(1 + ord(c))
        valueA = len(first) - first.count(c) + minimum_number(last, len(last), aux)
        valueB = len(last) - last.count(c) + minimum_number(first, len(first), aux)
        
        if valueA < valueB:
                return valueA
        else:
                return valueB
 
if __name__ == '__main__':
    main()