def count(s, l, r, char): # 97
    return sum([1 for i in range(l, r + 1) if ord(s[i]) != char])


def devide(s, l, r, ascii_char):
    if r == l:
        return 1 if ord(s[l]) != ascii_char else 0
    mid = (l + r) // 2
    left = devide(s, l, mid, ascii_char + 1) + count(s, mid + 1, r, ascii_char)
    rigth = devide(s, mid + 1, r, ascii_char + 1) + count(s, l, mid, ascii_char)
    return min(left, rigth)


if __name__ == '__main__':
    t = int(input())
    for _ in range(t):
        n = int(input())
        s = input()
        print(devide(s, 0, len(s) - 1, 97))
        
