def good(s, letter):
    if len(s) == 1:
        return 0 if s == letter else 1
    
    half = len(s) // 2
    first, second = s[:half], s[half:]
    
    return min(half - first.count(letter) + good(second, chr(ord(letter) + 1)),
        half - second.count(letter) + good(first, chr(ord(letter) + 1)))

def good_greedy(s, letter):
    if len(s) == 1:
        return 0 if s == letter else 1
    
    half = len(s) // 2
    first, second = s[:half], s[half:]
    
    if first.count(letter) > second.count(letter):
        return half - first.count(letter) + good_greedy(second, chr(ord(letter) + 1))
    else:
        return half - second.count(letter) + good_greedy(first, chr(ord(letter) + 1))

T = int(input())
for _ in range(T):
    n = int(input())
    s = input().strip()

    print(good(s, 'a'))